Skip to content

Commit

Permalink
refactor: remove redundant debugging logs
Browse files Browse the repository at this point in the history
  • Loading branch information
hopeyen committed Dec 16, 2024
1 parent ec149e0 commit d942bf5
Show file tree
Hide file tree
Showing 11 changed files with 17 additions and 61 deletions.
14 changes: 2 additions & 12 deletions core/eth/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package eth
import (
"context"
"crypto/ecdsa"
"fmt"
"math/big"
"strings"

Expand Down Expand Up @@ -141,7 +140,7 @@ func (t *Reader) updateContractBindings(blsOperatorStateRetrieverAddr, eigenDASe
return err
}

t.logger.Debug("Addresses!!!!!!!!!!!!!!", "blsOperatorStateRetrieverAddr", blsOperatorStateRetrieverAddr.Hex(), "eigenDAServiceManagerAddr", eigenDAServiceManagerAddr.Hex(), "registryCoordinatorAddr", registryCoordinatorAddr.Hex(), "blsPubkeyRegistryAddr", blsPubkeyRegistryAddr.Hex())
t.logger.Debug("Addresses", "blsOperatorStateRetrieverAddr", blsOperatorStateRetrieverAddr.Hex(), "eigenDAServiceManagerAddr", eigenDAServiceManagerAddr.Hex(), "registryCoordinatorAddr", registryCoordinatorAddr.Hex(), "blsPubkeyRegistryAddr", blsPubkeyRegistryAddr.Hex())

contractBLSPubkeyReg, err := blsapkreg.NewContractBLSApkRegistry(blsPubkeyRegistryAddr, t.ethClient)
if err != nil {
Expand Down Expand Up @@ -218,7 +217,7 @@ func (t *Reader) updateContractBindings(blsOperatorStateRetrieverAddr, eigenDASe
if err != nil {
t.logger.Error("Failed to fetch PaymentVault address", "err", err)
//TODO(hopeyen): return err when the contract is deployed
return err
// return err
} else {
contractPaymentVault, err = paymentvault.NewContractPaymentVault(paymentVaultAddr, t.ethClient)
if err != nil {
Expand All @@ -227,8 +226,6 @@ func (t *Reader) updateContractBindings(blsOperatorStateRetrieverAddr, eigenDASe
}
}

t.logger.Debug("Made payment vault binding", "contract addr", paymentVaultAddr, "contract struct", contractPaymentVault)

t.bindings = &ContractBindings{
ServiceManagerAddr: eigenDAServiceManagerAddr,
RegCoordinatorAddr: registryCoordinatorAddr,
Expand Down Expand Up @@ -599,10 +596,7 @@ func (t *Reader) CalculateOperatorChurnApprovalDigestHash(
}

func (t *Reader) GetCurrentBlockNumber(ctx context.Context) (uint32, error) {
fmt.Println("Getting current block number")
fmt.Println("ethClient", t.ethClient)
bn, err := t.ethClient.BlockNumber(ctx)
fmt.Println("Got current block number", bn)
return uint32(bn), err
}

Expand Down Expand Up @@ -739,12 +733,9 @@ func (t *Reader) GetReservedPayments(ctx context.Context, accountIDs []gethcommo
}

func (t *Reader) GetReservedPaymentByAccount(ctx context.Context, accountID gethcommon.Address) (*core.ReservedPayment, error) {
fmt.Println("Get reserved payment as reader", accountID)
if t.bindings.PaymentVault == nil {
fmt.Println("payment vault not deployed")
return nil, errors.New("payment vault not deployed")
}
fmt.Println("payment vault query")
reservation, err := t.bindings.PaymentVault.GetReservation(&bind.CallOpts{
Context: ctx,
}, accountID)
Expand Down Expand Up @@ -780,7 +771,6 @@ func (t *Reader) GetOnDemandPayments(ctx context.Context, accountIDs []gethcommo
}

func (t *Reader) GetOnDemandPaymentByAccount(ctx context.Context, accountID gethcommon.Address) (*core.OnDemandPayment, error) {
fmt.Println("Reader getOnDemandPaymentByAccount", accountID)
if t.bindings.PaymentVault == nil {
return nil, errors.New("payment vault not deployed")
}
Expand Down
8 changes: 0 additions & 8 deletions core/eth/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,15 +140,7 @@ func isZeroValuedReservation(reservation paymentvault.IPaymentVaultReservation)
// ConvertToReservedPayment converts a upstream binding data structure to local definition.
// Returns an error if the input reservation is zero-valued.
func ConvertToReservedPayment(reservation paymentvault.IPaymentVaultReservation) (*core.ReservedPayment, error) {
fmt.Println("Convert to reserved payment",
"SymbolsPerSecond", reservation.SymbolsPerSecond,
"StartTimestamp", reservation.StartTimestamp,
"EndTimestamp", reservation.EndTimestamp,
"QuorumNumbers", reservation.QuorumNumbers,
"QuorumSplits", reservation.QuorumSplits,
)
if isZeroValuedReservation(reservation) {
fmt.Println("zer valued")
return nil, fmt.Errorf("reservation is not a valid active reservation")
}

Expand Down
1 change: 0 additions & 1 deletion core/indexer/indexer_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ var _ = BeforeSuite(func() {
testConfig.Deployers[0].DeploySubgraphs = false

if testConfig.Environment.IsLocal() {
fmt.Println("Starting anvil core indexer indexer_suite_test")
testConfig.StartAnvil()

fmt.Println("Deploying experiment")
Expand Down
18 changes: 3 additions & 15 deletions core/meterer/onchain_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ func (pcs *OnchainPaymentState) RefreshOnchainPaymentState(ctx context.Context)

// GetReservedPaymentByAccount returns a pointer to the active reservation for the given account ID; no writes will be made to the reservation
func (pcs *OnchainPaymentState) GetReservedPaymentByAccount(ctx context.Context, accountID gethcommon.Address) (*core.ReservedPayment, error) {
fmt.Println("Getting reserved payment by account as onchainpaymentstate", accountID)
pcs.ReservationsLock.Lock()
defer pcs.ReservationsLock.Unlock()
if reservation, ok := (pcs.ReservedPayments)[accountID]; ok {
Expand All @@ -151,45 +150,34 @@ func (pcs *OnchainPaymentState) GetReservedPaymentByAccount(ctx context.Context,
}

// pulls the chain state
fmt.Println("get reserved payment from onchain", accountID)
res, err := pcs.tx.GetReservedPaymentByAccount(ctx, accountID)
if err != nil {
return nil, err
}
fmt.Println("Got reservation")
// pcs.ReservationsLock.Lock()
(pcs.ReservedPayments)[accountID] = res
// pcs.ReservationsLock.Unlock()

return res, nil
}

// GetOnDemandPaymentByAccount returns a pointer to the on-demand payment for the given account ID; no writes will be made to the payment
func (pcs *OnchainPaymentState) GetOnDemandPaymentByAccount(ctx context.Context, accountID gethcommon.Address) (*core.OnDemandPayment, error) {
fmt.Println("pcs getOnDemandPaymentByAccount", accountID)
pcs.OnDemandLocks.RLock()
defer pcs.OnDemandLocks.RUnlock()
pcs.OnDemandLocks.Lock()
defer pcs.OnDemandLocks.Unlock()
if payment, ok := (pcs.OnDemandPayments)[accountID]; ok {
return payment, nil
}
// pulls the chain state
fmt.Println("pcs getOnDemandPaymentByAccount pulls the chain state", accountID)
res, err := pcs.tx.GetOnDemandPaymentByAccount(ctx, accountID)
if err != nil {
return nil, err
}
fmt.Println("pcs getOnDemandPaymentByAccount got from chain state", res)
pcs.OnDemandLocks.Lock()

(pcs.OnDemandPayments)[accountID] = res
pcs.OnDemandLocks.Unlock()
return res, nil
}

func (pcs *OnchainPaymentState) GetOnDemandQuorumNumbers(ctx context.Context) ([]uint8, error) {
fmt.Println("Getting on demand quorum numbers")
fmt.Println("Getting on demand quorum numbers tx ", pcs.tx)
blockNumber, err := pcs.tx.GetCurrentBlockNumber(ctx)

if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion core/thegraph/state_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func setup() {
testConfig = deploy.NewTestConfig(testName, rootPath)
testConfig.Deployers[0].DeploySubgraphs = true

fmt.Println("Starting anvil ---------- core thegraph state_integration_test")
fmt.Println("Starting anvil")
testConfig.StartAnvil()

fmt.Println("Starting graph node")
Expand Down
11 changes: 0 additions & 11 deletions disperser/apiserver/server_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,6 @@ func (s *DispersalServerV2) GetPaymentState(ctx context.Context, req *pb.GetPaym
}()

accountID := gethcommon.HexToAddress(req.AccountId)
s.logger.Debug("Serve getpaymentstate request", accountID)

// validate the signature
if err := s.authenticator.AuthenticatePaymentStateRequest(req.GetSignature(), req.GetAccountId()); err != nil {
Expand All @@ -251,29 +250,24 @@ func (s *DispersalServerV2) GetPaymentState(ctx context.Context, req *pb.GetPaym
minNumSymbols := s.meterer.ChainPaymentState.GetMinNumSymbols()
pricePerSymbol := s.meterer.ChainPaymentState.GetPricePerSymbol()
reservationWindow := s.meterer.ChainPaymentState.GetReservationWindow()
s.logger.Debug("got on chain global params")

// off-chain account specific payment state
now := uint64(time.Now().Unix())
currentReservationPeriod := meterer.GetReservationPeriod(now, reservationWindow)
s.logger.Debug("now get bin records")
binRecords, err := s.meterer.OffchainStore.GetBinRecords(ctx, req.AccountId, currentReservationPeriod)
if err != nil {
s.logger.Debug("failed to get active reservation", err, accountID)
// return nil, api.NewErrorNotFound("failed to get active reservation")
binRecords = [3]*pb.BinRecord{}
}
s.logger.Debug("got bin records, now get largest cumulative payment")
largestCumulativePayment, err := s.meterer.OffchainStore.GetLargestCumulativePayment(ctx, req.AccountId)
if err != nil {
s.logger.Debug("err get largest cumulative payment", err)
// return nil, api.NewErrorNotFound("failed to get largest cumulative payment")
largestCumulativePayment = big.NewInt(0)
}
// on-Chain account state
fmt.Println("Getpaymentstate now getting reserved payment", accountID)
reservation, err := s.meterer.ChainPaymentState.GetReservedPaymentByAccount(ctx, accountID)
fmt.Println("Getpaymentstate getting reserved payment result", accountID)
if err != nil {
s.logger.Debug("cannot get reservation", err)
// return nil, api.NewErrorNotFound("failed to get active reservation")
Expand All @@ -285,18 +279,13 @@ func (s *DispersalServerV2) GetPaymentState(ctx context.Context, req *pb.GetPaym
QuorumSplits: []uint8{},
}
}
fmt.Println("Getpaymentstate now getting ondemand payment", accountID)
onDemandPayment, err := s.meterer.ChainPaymentState.GetOnDemandPaymentByAccount(ctx, accountID)
if err != nil {
s.logger.Debug("cannot get ondemand payment", err)
// return nil, api.NewErrorNotFound("failed to get on-demand payment")
onDemandPayment = &core.OnDemandPayment{CumulativePayment: big.NewInt(0)}
}
s.logger.Debug("Got onchain ondemand payment", onDemandPayment)
s.logger.Debug("Got onchain ondemand payment", onDemandPayment.CumulativePayment)
s.logger.Debug("Got onchain ondemand payment", onDemandPayment.CumulativePayment.Bytes())

s.logger.Debug("got payment global params; now build reply")
paymentGlobalParams := pb.PaymentGlobalParams{
GlobalSymbolsPerSecond: globalSymbolsPerSecond,
MinNumSymbols: minNumSymbols,
Expand Down
3 changes: 1 addition & 2 deletions disperser/cmd/apiserver/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ func RunDisperserServer(ctx *cli.Context) error {
UpdateInterval: time.Duration(config.UpdateInterval) * time.Second,
}

logger.Info("Creating onchain payment state apiserver main.go")
paymentChainState, err := mt.NewOnchainPaymentState(context.Background(), transactor)
if err != nil {
return fmt.Errorf("failed to create onchain payment state: %w", err)
Expand Down Expand Up @@ -139,7 +138,7 @@ func RunDisperserServer(ctx *cli.Context) error {
logger,
)
if err != nil {
return fmt.Errorf("failed to create offchain store (cmd apiserver main): %w", err)
return fmt.Errorf("failed to create offchain store: %w", err)
}
// add some default sensible configs
meterer = mt.NewMeterer(
Expand Down
2 changes: 1 addition & 1 deletion inabox/bin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ function stop_detached {

function start_anvil {

echo "Starting anvil server .... inabox bin.sh."
echo "Starting anvil server ....."
anvil --host 0.0.0.0 > /dev/null &
anvil_pid=$!
echo "Anvil server started ....."
Expand Down
15 changes: 7 additions & 8 deletions inabox/tests/integration_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,28 +85,27 @@ var _ = BeforeSuite(func() {
}
}

fmt.Println("Starting localstack!!!!!!!!!!!!!!!!!!!!!!!!!!!")

localStackPort = "4570"
pool, resource, err := deploy.StartDockertestWithLocalstackContainer(localStackPort)
Expect(err).To(BeNil())
dockertestPool = pool
dockertestResource = resource
testConfig = deploy.NewTestConfig(testName, rootPath)
if testConfig.Environment.IsLocal() {
if !inMemoryBlobStore {
fmt.Println("Using shared Blob Store")
localStackPort = "4570"
pool, resource, err := deploy.StartDockertestWithLocalstackContainer(localStackPort)
Expect(err).To(BeNil())
dockertestPool = pool
dockertestResource = resource

err = deploy.DeployResources(pool, localStackPort, metadataTableName, bucketTableName, metadataTableNameV2)
Expect(err).To(BeNil())
} else {
fmt.Println("Using in-memory Blob Store")
}

// fmt.Println("Making payment related tables....")
// err = deploy.DeployPaymentRelatedTables(pool, localStackPort)
// Expect(err).To(BeNil())

fmt.Println("Starting anvil inabox/tests/integration_suite_test.go")
fmt.Println("Starting anvil")
testConfig.StartAnvil()

if deployer, ok := testConfig.GetDeployer(testConfig.EigenDA.Deployer); ok && deployer.DeploySubgraphs {
Expand Down
2 changes: 1 addition & 1 deletion node/plugin/tests/plugin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func setup(m *testing.M) {
return
}

fmt.Println("Starting anvil node plugin tests plugin_test.go")
fmt.Println("Starting anvil")
testConfig.StartAnvil()

fmt.Println("Deploying experiment")
Expand Down
2 changes: 1 addition & 1 deletion operators/churner/tests/churner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func setup(m *testing.M) {
return
}

fmt.Println("Starting anvil operators churner tests churner_test.go")
fmt.Println("Starting anvil")
testConfig.StartAnvil()

fmt.Println("Deploying experiment")
Expand Down

0 comments on commit d942bf5

Please sign in to comment.