Skip to content

Commit

Permalink
added generate_eoa_transactions task
Browse files Browse the repository at this point in the history
  • Loading branch information
pk910 committed Dec 27, 2023
1 parent 68c5e77 commit 7e8a44e
Show file tree
Hide file tree
Showing 12 changed files with 1,014 additions and 266 deletions.
8 changes: 7 additions & 1 deletion pkg/coordinator/clients/execution/block.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package execution

import (
"context"
"sort"
"sync"
"time"
Expand Down Expand Up @@ -45,10 +46,15 @@ func (block *Block) GetBlock() *types.Block {
return block.block
}

func (block *Block) AwaitBlock(timeout time.Duration) *types.Block {
func (block *Block) AwaitBlock(ctx context.Context, timeout time.Duration) *types.Block {
if ctx == nil {
ctx = context.Background()
}

select {
case <-block.blockChan:
case <-time.After(timeout):
case <-ctx.Done():
}

return block.block
Expand Down
17 changes: 8 additions & 9 deletions pkg/coordinator/clients/execution/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ package execution
import (
"fmt"
"sync"

"github.com/ethereum/go-ethereum/common"
)

type SchedulerMode uint8
Expand All @@ -30,9 +28,6 @@ type Pool struct {
schedulerMode SchedulerMode
schedulerMutex sync.Mutex
rrLastIndexes map[ClientType]uint16

walletsMutex sync.Mutex
walletsMap map[common.Address]*Wallet
}

func NewPool(config *PoolConfig) (*Pool, error) {
Expand All @@ -41,7 +36,6 @@ func NewPool(config *PoolConfig) (*Pool, error) {
clients: make([]*Client, 0),
forkCache: map[int64][]*HeadFork{},
rrLastIndexes: map[ClientType]uint16{},
walletsMap: map[common.Address]*Wallet{},
}

var err error
Expand Down Expand Up @@ -84,6 +78,13 @@ func (pool *Pool) GetAllEndpoints() []*Client {
}

func (pool *Pool) GetReadyEndpoint(clientType ClientType) *Client {
readyClients := pool.GetReadyEndpoints()
selectedClient := pool.runClientScheduler(readyClients, clientType)

return selectedClient
}

func (pool *Pool) GetReadyEndpoints() []*Client {
canonicalFork := pool.GetCanonicalFork(-1)
if canonicalFork == nil {
return nil
Expand All @@ -94,9 +95,7 @@ func (pool *Pool) GetReadyEndpoint(clientType ClientType) *Client {
return nil
}

selectedClient := pool.runClientScheduler(readyClients, clientType)

return selectedClient
return readyClients
}

func (pool *Pool) IsClientReady(client *Client) bool {
Expand Down
255 changes: 0 additions & 255 deletions pkg/coordinator/clients/execution/wallet.go

This file was deleted.

7 changes: 7 additions & 0 deletions pkg/coordinator/coordinator.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/ethpandaops/assertoor/pkg/coordinator/test"
"github.com/ethpandaops/assertoor/pkg/coordinator/types"
"github.com/ethpandaops/assertoor/pkg/coordinator/vars"
"github.com/ethpandaops/assertoor/pkg/coordinator/wallet"
"github.com/ethpandaops/assertoor/pkg/coordinator/web/server"
"github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/sirupsen/logrus"
Expand All @@ -22,6 +23,7 @@ type Coordinator struct {
Config *Config
log logrus.FieldLogger
clientPool *clients.ClientPool
walletManager *wallet.Manager
webserver *server.WebServer
validatorNames *names.ValidatorNames
tests []types.Test
Expand Down Expand Up @@ -54,6 +56,7 @@ func (c *Coordinator) Run(ctx context.Context) error {
}

c.clientPool = clientPool
c.walletManager = wallet.NewManager(clientPool.GetExecutionPool(), c.log.WithField("module", "wallet"))

for idx := range c.Config.Endpoints {
err = clientPool.AddClient(&c.Config.Endpoints[idx])
Expand Down Expand Up @@ -128,6 +131,10 @@ func (c *Coordinator) ClientPool() *clients.ClientPool {
return c.clientPool
}

func (c *Coordinator) WalletManager() *wallet.Manager {
return c.walletManager
}

func (c *Coordinator) ValidatorNames() *names.ValidatorNames {
return c.validatorNames
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/coordinator/tasks/generate_deposits/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ func (t *Task) generateDeposit(ctx context.Context, accountIdx uint64, validator
return fmt.Errorf("cannot create bound instance of DepositContract: %w", err)
}

wallet, err := clientPool.GetExecutionPool().GetWalletByPrivkey(t.walletPrivKey)
wallet, err := t.ctx.Scheduler.GetCoordinator().WalletManager().GetWalletByPrivkey(t.walletPrivKey)
if err != nil {
return fmt.Errorf("cannot initialize wallet: %w", err)
}
Expand Down
Loading

0 comments on commit 7e8a44e

Please sign in to comment.