Skip to content
This repository has been archived by the owner on Jun 20, 2024. It is now read-only.

Commit

Permalink
Merge pull request #120 from primevprotocol/logmsg.0
Browse files Browse the repository at this point in the history
chore: improve log msg
  • Loading branch information
kant777 authored Dec 12, 2023
2 parents 22f15d8 + d864c37 commit 88fc8bb
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
15 changes: 15 additions & 0 deletions mev-commit-cli.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,17 @@ GETH_POA_PATH="$PRIMEV_DIR/go-ethereum"
CONTRACTS_PATH="$PRIMEV_DIR/contracts"
MEV_COMMIT_PATH="$PRIMEV_DIR/mev-commit"
DOCKER_NETWORK_NAME="primev_net"
MEV_COMMIT_BRANCH="main"
GETH_POA_BRANCH="master"
CONTRACTS_BRANCH="main"

# Function to initialize the environment
initialize_environment() {
create_primev_dir
create_docker_network
clone_repos
update_repos
checkout_branch
}

# Function to create a Docker network
Expand Down Expand Up @@ -41,6 +45,17 @@ clone_repos() {
[ ! -d "$MEV_COMMIT_PATH" ] && git clone https://github.com/primevprotocol/mev-commit.git "$MEV_COMMIT_PATH"
}

# Function to checkout a specific branch for all repositories
# If no branch is specified, the default branch is used
checkout_branch() {
echo "Checking out branch $MEV_COMMIT_BRANCH for mev-commit..."
git -C "$MEV_COMMIT_PATH" checkout "$MEV_COMMIT_BRANCH"
echo "Checking out branch $GETH_POA_BRANCH for go-ethereum..."
git -C "$GETH_POA_PATH" checkout "$GETH_POA_BRANCH"
echo "Checking out branch $CONTRACTS_BRANCH for contracts..."
git -C "$CONTRACTS_PATH" checkout "$CONTRACTS_BRANCH"
}

# Function to pull latest changes for all repositories
update_repos() {
echo "Updating repositories in $PRIMEV_DIR..."
Expand Down
17 changes: 15 additions & 2 deletions pkg/rpc/provider/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ package providerapi

import (
"context"
"encoding/hex"
"errors"
"fmt"
"log/slog"
"math/big"
"sync"
Expand Down Expand Up @@ -46,6 +48,13 @@ func NewService(
}
}

func toString(bid *providerapiv1.Bid) string {
return fmt.Sprintf(
"{TxHash: %s, BidAmount: %d, BlockNumber: %d, BidDigest: %x}",
bid.TxHash, bid.BidAmount, bid.BlockNumber, bid.BidDigest,
)
}

func (s *Service) ProcessBid(
ctx context.Context,
bid *preconfsigner.Bid,
Expand Down Expand Up @@ -88,7 +97,7 @@ func (s *Service) ReceiveBids(
s.logger.Error("context cancelled for receiving bid", "err", srv.Context().Err())
return srv.Context().Err()
case bid := <-s.receiver:
s.logger.Info("received bid from node", "bid", bid)
s.logger.Info("received bid from node", "bid", toString(bid))
err := srv.Send(bid)
if err != nil {
return err
Expand All @@ -111,7 +120,11 @@ func (s *Service) SendProcessedBids(srv providerapiv1.Provider_SendProcessedBids
s.bidsMu.Unlock()

if ok {
s.logger.Info("received bid status from node", "status", status)
s.logger.Info(
"received bid status from node",
"bidDigest", hex.EncodeToString(status.BidDigest),
"status", status.Status.String(),
)
callback(status.Status)
}
}
Expand Down

0 comments on commit 88fc8bb

Please sign in to comment.