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

compatible test image for 2.5.0-1.1.0 contracts #131

Closed
wants to merge 28 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
749aece
compatible test image for 2.5.0-1.1.0 contracts
AnieeG Sep 13, 2023
8c61ffb
Update contracts for test release
jasonmci Sep 13, 2023
d5dfc0c
network fix
AnieeG Sep 14, 2023
ea94203
fix test
AnieeG Sep 14, 2023
47a791f
Add missing config
jasonmci Sep 14, 2023
c05465d
Add native fee token to Base Goerli
jasonmci Sep 14, 2023
11d4fae
updates
AnieeG Sep 15, 2023
29dd76f
updates
AnieeG Sep 17, 2023
8081902
enable loki
AnieeG Sep 17, 2023
94eaa68
namespace changes
AnieeG Sep 18, 2023
f8e284e
Add lane config
jasonmci Sep 18, 2023
77f6ab8
Remove trailing comma
jasonmci Sep 18, 2023
dbf2b2d
updates
AnieeG Oct 2, 2023
83c2271
changes
AnieeG Oct 2, 2023
397b278
fix gasused
AnieeG Oct 2, 2023
48710c2
failonErr false
AnieeG Oct 3, 2023
10d8c43
Merge branch 'release/v2.5.0-ccip1.1.0' into test-release-2.5.0
AnieeG Oct 4, 2023
5732cf8
skip approving token
AnieeG Oct 24, 2023
7972508
Add bridge token and token pool for base mainnet
jasonmci Nov 3, 2023
d19ed11
Trigger a new test image
jasonmci Nov 9, 2023
edd5063
Uncomment ccip helpers function
jasonmci Nov 22, 2023
f8ef5be
skip validation
AnieeG Nov 22, 2023
e8fb5cf
Update base and bsc to use native token
jasonmci Dec 21, 2023
ea4e0c7
comment approve token
AnieeG Dec 21, 2023
33cfbc7
Update lane configs
jasonmci Jan 9, 2024
f22d1f4
Uncomment and change to allow more flex in balance amts
jasonmci Jan 11, 2024
92fff76
Update lanes to use LINK for Poly and BSC
jasonmci Jan 12, 2024
b1a94ae
Update contracts to use native only and remove any tokens not needed
jasonmci Jan 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions core/scripts/ccip/ccip-send/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package ccip_send
122 changes: 75 additions & 47 deletions integration-tests/actions/ccip_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ var (
return fmt.Sprintf("%s-ethereum-geth", name)
}
// ApprovedAmountToRouter is the default amount which gets approved for router so that it can transfer token and use the fee token for fee payment
ApprovedAmountToRouter = new(big.Int).Mul(big.NewInt(1e18), big.NewInt(200))
ApprovedAmountToRouter = new(big.Int).Mul(big.NewInt(1e18), big.NewInt(1))
ApprovedFeeAmountToRouter = new(big.Int).Mul(big.NewInt(int64(GasFeeMultiplier)), big.NewInt(1e5))
GasFeeMultiplier uint64 = 12e17
LinkToUSD = big.NewInt(6e18)
Expand Down Expand Up @@ -467,14 +467,18 @@ func (sourceCCIP *SourceCCIPModule) DeployContracts(lane *laneconfig.LaneConfig)
return errors.WithStack(err)
}

err = sourceCCIP.Common.ApproveTokens()
if err != nil {
return err
}

err = sourceCCIP.Common.ApproveTokens()
if err != nil {
return err
}



sourceCCIP.LoadContracts(lane)
// update transfer amount array length to be equal to the number of tokens
// each index in TransferAmount array corresponds to the amount to be transferred for the token at the same index in BridgeTokens array
if len(sourceCCIP.TransferAmount) != len(sourceCCIP.Common.BridgeTokens) {
if len(sourceCCIP.TransferAmount) != len(sourceCCIP.Common.BridgeTokens) && len(sourceCCIP.TransferAmount) > 0 {
sourceCCIP.TransferAmount = sourceCCIP.TransferAmount[:len(sourceCCIP.Common.BridgeTokens)]
}
sourceChainSelector, err := chainselectors.SelectorFromChainId(sourceCCIP.Common.ChainClient.GetChainID().Uint64())
Expand Down Expand Up @@ -674,23 +678,24 @@ func (sourceCCIP *SourceCCIPModule) UpdateBalance(
totalFee *big.Int,
balances *BalanceSheet,
) {
for i, token := range sourceCCIP.Common.BridgeTokens {
name := fmt.Sprintf("BridgeToken-%s-Address-%s", token.Address(), sourceCCIP.Sender.Hex())
balances.Update(name, BalanceItem{
Address: sourceCCIP.Sender,
Getter: GetterForLinkToken(token.BalanceOf, sourceCCIP.Sender.Hex()),
AmtToSub: bigmath.Mul(big.NewInt(noOfReq), sourceCCIP.TransferAmount[i]),
})
}
for i, pool := range sourceCCIP.Common.BridgeTokenPools {
name := fmt.Sprintf("BridgeToken-%s-TokenPool-%s", sourceCCIP.Common.BridgeTokens[i].Address(), pool.Address())
balances.Update(name, BalanceItem{
Address: pool.EthAddress,
Getter: GetterForLinkToken(sourceCCIP.Common.BridgeTokens[i].BalanceOf, pool.Address()),
AmtToAdd: bigmath.Mul(big.NewInt(noOfReq), sourceCCIP.TransferAmount[i]),
})
if len(sourceCCIP.TransferAmount) > 0 {
for i, token := range sourceCCIP.Common.BridgeTokens {
name := fmt.Sprintf("BridgeToken-%s-Address-%s", token.Address(), sourceCCIP.Sender.Hex())
balances.Update(name, BalanceItem{
Address: sourceCCIP.Sender,
Getter: GetterForLinkToken(token.BalanceOf, sourceCCIP.Sender.Hex()),
AmtToSub: bigmath.Mul(big.NewInt(noOfReq), sourceCCIP.TransferAmount[i]),
})
}
for i, pool := range sourceCCIP.Common.BridgeTokenPools {
name := fmt.Sprintf("BridgeToken-%s-TokenPool-%s", sourceCCIP.Common.BridgeTokens[i].Address(), pool.Address())
balances.Update(name, BalanceItem{
Address: pool.EthAddress,
Getter: GetterForLinkToken(sourceCCIP.Common.BridgeTokens[i].BalanceOf, pool.Address()),
AmtToAdd: bigmath.Mul(big.NewInt(noOfReq), sourceCCIP.TransferAmount[i]),
})
}
}

if sourceCCIP.Common.FeeToken.Address() != common.HexToAddress("0x0").String() {
name := fmt.Sprintf("FeeToken-%s-Address-%s", sourceCCIP.Common.FeeToken.Address(), sourceCCIP.Sender.Hex())
balances.Update(name, BalanceItem{
Expand Down Expand Up @@ -817,7 +822,7 @@ func (sourceCCIP *SourceCCIPModule) SendRequest(
FeeToken: feeToken,
ExtraArgs: extraArgsV1,
}
log.Info().Interface("ge msg details", msg).Msg("ccip message to be sent")
log.Info().Interface("msg details", msg).Msg("ccip message to be sent")
fee, err := sourceCCIP.Common.Router.GetFee(destChainSelector, msg)
if err != nil {
reason, _ := blockchain.RPCErrorFromError(err)
Expand Down Expand Up @@ -1138,21 +1143,23 @@ func (destCCIP *DestCCIPModule) UpdateBalance(
noOfReq int64,
balance *BalanceSheet,
) {
for i, token := range destCCIP.Common.BridgeTokens {
name := fmt.Sprintf("BridgeToken-%s-Address-%s", token.Address(), destCCIP.ReceiverDapp.Address())
balance.Update(name, BalanceItem{
Address: destCCIP.ReceiverDapp.EthAddress,
Getter: GetterForLinkToken(token.BalanceOf, destCCIP.ReceiverDapp.Address()),
AmtToAdd: bigmath.Mul(big.NewInt(noOfReq), transferAmount[i]),
})
}
for i, pool := range destCCIP.Common.BridgeTokenPools {
name := fmt.Sprintf("BridgeToken-%s-TokenPool-%s", destCCIP.Common.BridgeTokens[i].Address(), pool.Address())
balance.Update(name, BalanceItem{
Address: pool.EthAddress,
Getter: GetterForLinkToken(destCCIP.Common.BridgeTokens[i].BalanceOf, pool.Address()),
AmtToSub: bigmath.Mul(big.NewInt(noOfReq), transferAmount[i]),
})
if len(transferAmount) > 0 {
for i, token := range destCCIP.Common.BridgeTokens {
name := fmt.Sprintf("BridgeToken-%s-Address-%s", token.Address(), destCCIP.ReceiverDapp.Address())
balance.Update(name, BalanceItem{
Address: destCCIP.ReceiverDapp.EthAddress,
Getter: GetterForLinkToken(token.BalanceOf, destCCIP.ReceiverDapp.Address()),
AmtToAdd: bigmath.Mul(big.NewInt(noOfReq), transferAmount[i]),
})
}
for i, pool := range destCCIP.Common.BridgeTokenPools {
name := fmt.Sprintf("BridgeToken-%s-TokenPool-%s", destCCIP.Common.BridgeTokens[i].Address(), pool.Address())
balance.Update(name, BalanceItem{
Address: pool.EthAddress,
Getter: GetterForLinkToken(destCCIP.Common.BridgeTokens[i].BalanceOf, pool.Address()),
AmtToSub: bigmath.Mul(big.NewInt(noOfReq), transferAmount[i]),
})
}
}
if destCCIP.Common.FeeToken.Address() != common.HexToAddress("0x0").String() {
name := fmt.Sprintf("FeeToken-%s-OffRamp-%s", destCCIP.Common.FeeToken.Address(), destCCIP.OffRamp.Address())
Expand Down Expand Up @@ -1198,12 +1205,16 @@ func (destCCIP *DestCCIPModule) AssertEventExecutionStateChanged(
if err != nil {
lggr.Warn().Msg("Failed to get receipt for ExecStateChanged event")
}
var gasUsed uint64
if receipt != nil {
gasUsed = receipt.GasUsed
}
if abihelpers.MessageExecutionState(e.State) == abihelpers.ExecutionStateSuccess {
reports.UpdatePhaseStats(reqNo, seqNum, testreporters.ExecStateChanged, receivedAt.Sub(timeNow),
testreporters.Success,
testreporters.TransactionStats{
TxHash: vLogs.TxHash.Hex(),
GasUsed: receipt.GasUsed,
GasUsed: gasUsed,
})
return nil
} else {
Expand Down Expand Up @@ -1263,9 +1274,13 @@ func (destCCIP *DestCCIPModule) AssertEventReportAccepted(
if err != nil {
lggr.Warn().Msg("Failed to get receipt for ReportAccepted event")
}
var gasUsed uint64
if receipt != nil {
gasUsed = receipt.GasUsed
}
reports.UpdatePhaseStats(reqNo, seqNum, testreporters.Commit, totalTime, testreporters.Success,
testreporters.TransactionStats{
GasUsed: receipt.GasUsed,
GasUsed: gasUsed,
TxHash: reportAccepted.Raw.TxHash.String(),
CommitRoot: fmt.Sprintf("%x", reportAccepted.Report.MerkleRoot),
})
Expand Down Expand Up @@ -1312,9 +1327,13 @@ func (destCCIP *DestCCIPModule) AssertReportBlessed(
if err != nil {
lggr.Fatal().Err(err).Msg("Failed to get receipt for ReportBlessed event")
}
var gasUsed uint64
if receipt != nil {
gasUsed = receipt.GasUsed
}
reports.UpdatePhaseStats(reqNo, seqNum, testreporters.ReportBlessed, receivedAt.Sub(prevEventAt), testreporters.Success,
testreporters.TransactionStats{
GasUsed: receipt.GasUsed,
GasUsed: gasUsed,
TxHash: vLogs.TxHash.String(),
CommitRoot: fmt.Sprintf("%x", CommitReport.MerkleRoot),
})
Expand Down Expand Up @@ -1432,6 +1451,7 @@ type CCIPLane struct {
SrcNetworkLaneCfg *laneconfig.LaneConfig
DstNetworkLaneCfg *laneconfig.LaneConfig
Subscriptions []event.Subscription
SkipValidation bool
}

func (lane *CCIPLane) UpdateLaneConfig() {
Expand Down Expand Up @@ -1581,11 +1601,17 @@ func (lane *CCIPLane) ValidateRequests() {
}
// Asserting balances reliably work only for simulated private chains. The testnet contract balances might get updated by other transactions
// verify the fee amount is deducted from sender, added to receiver token balances and
lane.Source.UpdateBalance(int64(lane.NumberOfReq), lane.TotalFee, lane.Balance)
lane.Dest.UpdateBalance(lane.Source.TransferAmount, int64(lane.NumberOfReq), lane.Balance)
if len(lane.Source.TransferAmount) > 0 {
lane.Source.UpdateBalance(int64(lane.NumberOfReq), lane.TotalFee, lane.Balance)
lane.Dest.UpdateBalance(lane.Source.TransferAmount, int64(lane.NumberOfReq), lane.Balance)
}
}

func (lane *CCIPLane) ValidateRequestByTxHash(txHash string, txConfirmattion time.Time, reqNo int64) error {
if lane.SkipValidation {
lane.Logger.Info().Msg("Skipping validation")
return nil
}
msgLog, ccipSendReqGenAt, err := lane.Source.AssertEventCCIPSendRequested(
lane.Logger, reqNo, txHash, lane.ValidationTimeout, txConfirmattion, lane.Reports)
if err != nil || msgLog == nil {
Expand Down Expand Up @@ -1777,10 +1803,12 @@ func (lane *CCIPLane) DeployNewCCIPLane(
}
lane.UpdateLaneConfig()

// start event watchers
err = lane.StartEventWatchers()
if err != nil {
return errors.WithStack(err)
if !lane.SkipValidation {
// start event watchers
err = lane.StartEventWatchers()
if err != nil {
return errors.WithStack(err)
}
}
// if lane is being set up for already configured CL nodes and contracts
// no further action is necessary
Expand Down
Loading
Loading