Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions infrastructure/docker/Dockerfile.builder
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ COPY cl/go.mod cl/go.sum ./cl/
COPY infrastructure/tools/keystore-generator/go.mod infrastructure/tools/keystore-generator/go.sum ./infrastructure/tools/keystore-generator/

COPY p2p/integrationtest/provider/entrypoint.sh /scripts/provider-emulator-entrypoint.sh
COPY p2p/integrationtest/real-bidder/entrypoint.sh /scripts/realbidder-emulator-entrypoint.sh

RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg/mod \
Expand All @@ -39,6 +40,7 @@ ARG TARGETS="./oracle/cmd \
./tools/validators-monitor \
./tools/points-service \
./p2p/integrationtest/provider \
./p2p/integrationtest/real-bidder \
./cl/cmd/singlenode"

RUN --mount=type=cache,target=/root/.cache/go-build \
Expand Down
9 changes: 9 additions & 0 deletions infrastructure/docker/Dockerfile.realbidder
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# syntax=docker/dockerfile:1.4
FROM alpine:3.10

COPY --from=builder_ctx /go/bin/real-bidder /usr/local/bin/bidder-emulator
COPY --from=builder_ctx /scripts/realbidder-emulator-entrypoint.sh entrypoint.sh

EXPOSE 8080

ENTRYPOINT ["./entrypoint.sh"]
12 changes: 12 additions & 0 deletions infrastructure/docker/docker-bake.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,17 @@ target "snode" {
labels = get_labels("snode")
}

target "realbidder-emulator" {
inherits = ["_common"]
context = "./"
dockerfile = "Dockerfile.realbidder"
contexts = {
builder_ctx = "target:mev-commit-builder"
}
tags = [REPO_NAME != "" ? "${REGISTRY}/${REPO_NAME}:${TAG}-realbidder-emulator" : "${REGISTRY}/realbidder-emulator:${TAG}"]
labels = get_labels("realbidder-emulator")
}

group "all" {
targets = [
"mev-commit-builder",
Expand All @@ -150,6 +161,7 @@ group "all" {
"preconf-rpc",
"bidder-emulator",
"provider-emulator",
"realbidder-emulator",
"relay-emulator",
"snode"
]
Expand Down
2 changes: 1 addition & 1 deletion oracle/pkg/node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func NewNode(opts *Options) (*Node, error) {
txmonitor.NewEVMHelperWithLogger(settlementClient, nd.logger, contracts),
st,
nd.logger.With("component", "tx_monitor"),
1024,
2048,
)

ctx, cancel := context.WithCancel(context.Background())
Expand Down
2 changes: 1 addition & 1 deletion p2p/integrationtest/provider/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ func main() {
err = providerClient.SendBidResponse(context.Background(), &providerapiv1.BidResponse{
BidDigest: bid.BidDigest,
Status: status,
DispatchTimestamp: time.Now().UnixMilli(),
DispatchTimestamp: time.Now().Add(2 * time.Second).UnixMilli(),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is needed due to high tx load?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes.... instead of changing the contract value, this is easier.

})
if err != nil {
logger.Error("failed to send bid response", "error", err)
Expand Down
111 changes: 44 additions & 67 deletions p2p/integrationtest/real-bidder/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ var (
)
bidWorkers = flag.Int(
"bid-workers",
2,
10,
"Number of workers to send bids",
)
)
Expand Down Expand Up @@ -206,7 +206,7 @@ func main() {
}
logger.Info("deposit manager enabled")

var providerAddress string
var providerAddresses []string
retries := 10
for range retries {
resp, err := bidderClient.GetValidProviders(context.Background(), &pb.GetValidProvidersRequest{})
Expand All @@ -215,24 +215,27 @@ func main() {
continue
}
if len(resp.ValidProviders) > 0 {
providerAddress = resp.ValidProviders[0]
providerAddresses = resp.ValidProviders
break
}
time.Sleep(time.Second)
}

if providerAddress == "" {
if len(providerAddresses) == 0 {
logger.Error("no connected and valid provider found")
return
}

targetDeposits := make([]*pb.TargetDeposit, len(providerAddresses))
for i, addr := range providerAddresses {
targetDeposits[i] = &pb.TargetDeposit{
TargetDeposit: minDeposit.String(),
Provider: addr,
}
}

resp, err := bidderClient.SetTargetDeposits(context.Background(), &pb.SetTargetDepositsRequest{
TargetDeposits: []*pb.TargetDeposit{
{
TargetDeposit: minDeposit.String(),
Provider: providerAddress,
},
},
TargetDeposits: targetDeposits,
})
if err != nil {
logger.Error("failed to set target deposits", "err", err)
Expand All @@ -250,10 +253,7 @@ func main() {
txns []string
}

blockChans := make([]chan *blockWithTxns, *bidWorkers)
for i := 0; i < *bidWorkers; i++ {
blockChans[i] = make(chan *blockWithTxns, 1)
}
blockChan := make(chan *blockWithTxns, 1)

wg.Add(1)
go func(logger *slog.Logger) {
Expand All @@ -279,63 +279,40 @@ func main() {
}

currentBlkNum = blkNum
for _, ch := range blockChans {
txns := make([]string, len(block))
copy(txns, block)

ch <- &blockWithTxns{
blockNum: int64(blkNum),
txns: txns,
}
blockChan <- &blockWithTxns{
blockNum: int64(blkNum),
txns: block,
}
}
}(logger)

for i := 0; i < *bidWorkers; i++ {
wg.Add(1)
go func(logger *slog.Logger, newBlockChan <-chan *blockWithTxns) {
defer wg.Done()
ticker := time.NewTicker(200 * time.Millisecond)
currentBlock := &blockWithTxns{}
for {
select {
case block := <-newBlockChan:
if block.blockNum <= currentBlock.blockNum {
continue
workerSem := make(chan struct{}, *bidWorkers)

wg.Add(1)
go func(logger *slog.Logger) {
defer wg.Done()

for blockWithTxn := range blockChan {
logger.Info("new block received", "blockNum", blockWithTxn.blockNum, "numTxns", len(blockWithTxn.txns))
for _, txn := range blockWithTxn.txns {
workerSem <- struct{}{}
go func(txn string) {
defer func() { <-workerSem }()
err := sendBid(
bidderClient,
logger,
[]string{txn},
blockWithTxn.blockNum,
time.Now().Add(500*time.Millisecond).UnixMilli(),
time.Now().Add(6*time.Second).UnixMilli(),
)
if err != nil {
logger.Error("failed to send bid", "err", err)
}
currentBlock = block
case <-ticker.C:
}

if len(currentBlock.txns) == 0 {
continue
}

bundleLen := rand.Intn(10) + 1
bundleStart := rand.Intn(len(currentBlock.txns))
bundleEnd := bundleStart + bundleLen
if bundleEnd >= len(currentBlock.txns) {
bundleEnd = len(currentBlock.txns)
}

min := 5000
max := 10000
startTimeDiff := rand.Intn(max-min+1) + min
endTimeDiff := rand.Intn(max-min+1) + min
err = sendBid(
bidderClient,
logger,
currentBlock.txns[bundleStart:bundleEnd],
currentBlock.blockNum,
(time.Now().UnixMilli())-int64(startTimeDiff),
(time.Now().UnixMilli())+int64(endTimeDiff),
)
if err != nil {
logger.Error("failed to send bid", "err", err)
}
}(txn)
}
}(logger, blockChans[i])
}
}
}(logger)

wg.Wait()
}
Expand Down Expand Up @@ -370,8 +347,8 @@ func sendBid(
if len(txnHashes) == 0 {
return errors.New("no txns to send")
}
amount := rand.Intn(200000)
amount += 100000
amount := rand.Intn(2000000000)
amount += 1000000000

hashesToSend := make([]string, len(txnHashes))
copy(hashesToSend, txnHashes)
Expand Down
2 changes: 1 addition & 1 deletion p2p/pkg/node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ func NewNode(opts *Options) (*Node, error) {
txmonitor.NewEVMHelperWithLogger(contractRPC, opts.Logger.With("component", "txmonitor"), contracts),
txnStore,
opts.Logger.With("component", "txmonitor"),
1024,
2048,
)
startables = append(
startables,
Expand Down
Loading