Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
0xAustinWang committed Jan 15, 2025
1 parent 92649b9 commit 6e439df
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 36 deletions.
16 changes: 6 additions & 10 deletions deployment/environment/crib/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package crib

import (
"context"
"fmt"
"math/big"

"github.com/ethereum/go-ethereum/common"
Expand All @@ -17,7 +16,6 @@ import (
)

func distributeFunds(lggr logger.Logger, nodeInfo []devenv.Node, env deployment.Environment) {
fmt.Println("Funding transmitters...")
transmittersStr := make([]common.Address, 0)
fundingAmount := big.NewInt(500_000_000_000_000_000) // 0.5 ETH
minThreshold := big.NewInt(50_000_000_000_000_000) // 0.05 ETH
Expand All @@ -34,17 +32,15 @@ func distributeFunds(lggr logger.Logger, nodeInfo []devenv.Node, env deployment.
addr := common.HexToAddress(n.AccountAddr[chainId])
balance, err := chain.Client.BalanceAt(context.Background(), addr, nil)
if err != nil {
fmt.Printf("Error fetching balance for %s: %v\n", n, err)
lggr.Errorw("error fetching balance for %s: %v\n", n.Name, err)
continue
}
if balance.Cmp(minThreshold) < 0 {
fmt.Printf(
"Transmitter %s with address %s, has insufficient funds, funding with %s ETH. Current balance: %s, threshold: %s\n",
n.Name,
addr.String(),
conversions.WeiToEther(fundingAmount).String(),
conversions.WeiToEther(balance).String(),
conversions.WeiToEther(minThreshold).String(),
lggr.Infow(
"sending funds to",
"node", n.Name,
"address", addr.String(),
"amount", conversions.WeiToEther(fundingAmount).String(),
)
transmittersStr = append(transmittersStr, addr)
}
Expand Down
18 changes: 11 additions & 7 deletions integration-tests/load/ccip/ccip_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package ccip

import (
"fmt"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/smartcontractkit/chainlink-common/pkg/logger"
"github.com/smartcontractkit/chainlink-common/pkg/utils/tests"
Expand Down Expand Up @@ -88,13 +87,21 @@ func TestCCIPLoad_RPS(t *testing.T) {
}
}

loadDuration, err := time.ParseDuration(*userOverrides.LoadDuration)
require.NoError(t, err)
requestFrequency, err := time.ParseDuration(*userOverrides.RequestFrequency)
require.NoError(t, err)

for _, gun := range gunMap {
p.Add(wasp.NewGenerator(&wasp.Config{
T: t,
GenName: "ccipLoad",
LoadType: wasp.RPS,
CallTimeout: 5 * time.Second,
Schedule: wasp.Plain(1, time.Duration(*userOverrides.RequestFrequency)*time.Second),
// 1 request per second for n seconds
Schedule: wasp.Plain(1, loadDuration),
// limit requests to 1 per duration
RateLimitUnitDuration: requestFrequency,
// will need to be divided by number of chains
// this schedule is per generator
// in this example, it would be 1 request per 5seconds per generator (dest chain)
Expand Down Expand Up @@ -164,7 +171,7 @@ func TestCCIPLoad_RPS(t *testing.T) {
Timestamp: timestamp,
SequenceNumber: i,
})
fmt.Printf("Pushed loki for seqNumber %d\n", i)
lggr.Infow("pushed loki commit event for ", "seqNumber", i, "src", root.SourceChainSelector, "dest", chainSelector)

}
}
Expand All @@ -184,9 +191,6 @@ func TestCCIPLoad_RPS(t *testing.T) {
require.NoError(t, err)

for execIterator.Next() {
event := execIterator.Event
fmt.Printf("ExecutionStateChanged event: %+v\n", event)

blockNum := execIterator.Event.Raw.BlockNumber
header, err := env.Chains[chainSelector].Client.HeaderByNumber(ctx, big.NewInt(int64(blockNum)))
require.NoError(t, err)
Expand All @@ -202,7 +206,7 @@ func TestCCIPLoad_RPS(t *testing.T) {
GasUsed: execIterator.Event.GasUsed.Uint64(),
SequenceNumber: execIterator.Event.SequenceNumber,
})
fmt.Printf("Pushed loki exec for seqNumber %d\n", execIterator.Event.SequenceNumber)
lggr.Infow("pushed loki exec event for ", "seqNumber", execIterator.Event.SequenceNumber, "src", execIterator.Event.SourceChainSelector, "dest", chainSelector)
}
}(sourceCS, startBlock, filterOpts)
}
Expand Down
31 changes: 20 additions & 11 deletions integration-tests/load/ccip/destination_gun.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,6 @@ func (m *DestinationGun) Call(_ *wasp.Generator) *wasp.Response {
SourceChainSelector: src,
DestChainSelector: m.chainSelector,
}
m.l.Infow("Starting transmit with ",
"RoundNum", requestedRound,
"Source ChainSelector", src,
"Destination ChainSelector", m.chainSelector)

r := state.Chains[src].Router

Expand All @@ -121,29 +117,43 @@ func (m *DestinationGun) Call(_ *wasp.Generator) *wasp.Response {
fee, err := r.GetFee(
&bind.CallOpts{Context: context.Background()}, m.chainSelector, msg)
if err != nil {
m.l.Errorw("could not get fee ", "dstChainSelector", m.chainSelector, "msg", msg, "fee", fee, "err", err)
m.l.Errorw("could not get fee ",
"dstChainSelector", m.chainSelector,
"msg", msg,
"fee", fee,
"err", deployment.MaybeDataErr(err))
return &wasp.Response{Error: err.Error(), Group: waspGroup, Failed: true}
}
m.l.Debugw("setting fee for ", "srcChain", src, "dstChain", m.chainSelector, "fee", fee, "msg", msg)
if msg.FeeToken == common.HexToAddress("0x0") {
m.env.Chains[src].DeployerKey.Value = fee
defer func() { m.env.Chains[src].DeployerKey.Value = nil }()
}
m.l.Debugw("sending message ",
"srcChain", src,
"dstChain", m.chainSelector,
"round", requestedRound,
"fee", fee,
"msg", msg)
tx, err := r.CcipSend(
m.env.Chains[src].DeployerKey,
m.chainSelector,
msg)
if err != nil {
m.l.Errorw("execution reverted from ", "sourceChain", src, "destchain", m.chainSelector, "err", err, "tx", tx)
m.l.Errorw("execution reverted from ",
"sourceChain", src,
"destchain", m.chainSelector,
"err", deployment.MaybeDataErr(err))
return &wasp.Response{Error: err.Error(), Group: waspGroup, Failed: true}
}

blockNum, err := m.env.Chains[src].Confirm(tx)
if err != nil {
m.l.Errorw("could not confirm tx on source", "tx", tx, "err", err)
m.l.Errorw("could not confirm tx on source", "tx", tx, "err", deployment.MaybeDataErr(err))
return &wasp.Response{Error: err.Error(), Group: waspGroup, Failed: true}
}

// todo: wasp should not manage confirming the message
// instead, we should manage the sequence number atomically (at a higher level)
it, err := state.Chains[src].OnRamp.FilterCCIPMessageSent(&bind.FilterOpts{
Start: blockNum,
End: &blockNum,
Expand Down Expand Up @@ -185,7 +195,6 @@ func (m *DestinationGun) Call(_ *wasp.Generator) *wasp.Response {

// MustSourceChain will return a chain selector to send a message from
func (m *DestinationGun) MustSourceChain() (uint64, error) {

// TODO: make this smarter by checking if this chain has sent a message recently, if so, switch to the next chain
// Currently performing a round robin
otherCS := m.env.AllChainSelectorsExcluding([]uint64{m.chainSelector})
Expand All @@ -207,7 +216,7 @@ func (m *DestinationGun) GetMessage() (router.ClientEVM2AnyMessage, error) {
messages := []router.ClientEVM2AnyMessage{
{
Receiver: rcv,
Data: common.Hex2Bytes("message"),
Data: common.Hex2Bytes("0xabcdefabcdef"),
TokenAmounts: nil,
FeeToken: common.HexToAddress("0x0"),
ExtraArgs: nil,
Expand All @@ -220,7 +229,7 @@ func (m *DestinationGun) GetMessage() (router.ClientEVM2AnyMessage, error) {
Amount: big.NewInt(100),
},
},
Data: common.Hex2Bytes("hello world"),
Data: common.Hex2Bytes("0xabcdefabcdef"),
FeeToken: common.HexToAddress("0x0"),
ExtraArgs: nil,
},
Expand Down

This file was deleted.

This file was deleted.

10 changes: 5 additions & 5 deletions integration-tests/testconfig/ccip/ccip.toml
Original file line number Diff line number Diff line change
Expand Up @@ -244,12 +244,12 @@ ephemeral_addresses_number = 0
[Load.CCIP.Load]
# replace this with the loki endpoint of the crib stack
LokiEndpoint = "http://loki.localhost/loki/api/v1/push"
LoadDuration = "1m"
# corresponds to [data only, token only, message with data]
# MessageTypeWeights corresponds with [data only, token only, message with data]
MessageTypeWeights = [100,0,0]
# each destination chain will receive 1 request per RequestFrequency
RequestFrequency = 10
# each destination chain will receive 1 incoming request per RequestFrequency for the duration of LoadDuration
LoadDuration = "1m"
RequestFrequency = "10s"
# destination chain selectors to send messages to
EnabledDestionationChains = [3379446385462418246]
EnabledDestionationChains = [3379446385462418246, 909606746561742123]
# Directory where we receive environment configuration from crib
CribEnvDirectory = "/Users/austin.wang/ccip-core/repos/crib/deployments/ccip-v2/.tmp"
2 changes: 1 addition & 1 deletion integration-tests/testconfig/ccip/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ type LoadConfig struct {
NoOfNodes *int
LokiEndpoint *string
MessageTypeWeights *[]int
RequestFrequency *int
RequestFrequency *string
EnabledDestionationChains *[]uint64
CribEnvDirectory *string
}

0 comments on commit 6e439df

Please sign in to comment.