Skip to content

Commit 5d86333

Browse files
committed
add more task outputs to various tasks
1 parent dc01df2 commit 5d86333

8 files changed

Lines changed: 154 additions & 41 deletions

File tree

pkg/coordinator/tasks/check_consensus_slot_range/task.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,10 @@ func (t *Task) runRangeCheck() (checkResult, isLower bool) {
109109
return false, true
110110
}
111111

112+
t.ctx.Outputs.SetVar("genesisTime", consensusPool.GetBlockCache().GetGenesis().GenesisTime.Unix())
113+
t.ctx.Outputs.SetVar("currentSlot", currentSlot.Number())
114+
t.ctx.Outputs.SetVar("currentEpoch", currentEpoch.Number())
115+
112116
if currentSlot.Number() < t.config.MinSlotNumber {
113117
return false, true
114118
}

pkg/coordinator/tasks/check_consensus_sync_status/task.go

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"github.com/ethpandaops/assertoor/pkg/coordinator/clients"
99
"github.com/ethpandaops/assertoor/pkg/coordinator/clients/consensus/rpc"
1010
"github.com/ethpandaops/assertoor/pkg/coordinator/types"
11+
"github.com/ethpandaops/assertoor/pkg/coordinator/vars"
1112
"github.com/sirupsen/logrus"
1213
)
1314

@@ -29,6 +30,14 @@ type Task struct {
2930
firstHeight map[uint16]uint64
3031
}
3132

33+
type ClientInfo struct {
34+
Name string `json:"name"`
35+
Optimistic bool `json:"optimistic"`
36+
Synchronizing bool `json:"synchronizing"`
37+
SyncHead uint64 `json:"syncHead"`
38+
SyncDistance uint64 `json:"syncDistance"`
39+
}
40+
3241
func NewTask(ctx *types.TaskContext, options *types.TaskOptions) (types.Task, error) {
3342
return &Task{
3443
ctx: ctx,
@@ -87,7 +96,9 @@ func (t *Task) Execute(ctx context.Context) error {
8796

8897
func (t *Task) processCheck(ctx context.Context) {
8998
allResultsPass := true
90-
failedClients := []string{}
99+
goodClients := []*ClientInfo{}
100+
failedClients := []*ClientInfo{}
101+
failedClientNames := []string{}
91102

92103
for _, client := range t.ctx.Scheduler.GetServices().ClientPool().GetClientsByNamePatterns(t.config.ClientPattern, "") {
93104
var checkResult bool
@@ -110,11 +121,26 @@ func (t *Task) processCheck(ctx context.Context) {
110121
if !checkResult {
111122
allResultsPass = false
112123

113-
failedClients = append(failedClients, client.Config.Name)
124+
failedClients = append(failedClients, t.getClientInfo(client, syncStatus))
125+
failedClientNames = append(failedClientNames, client.Config.Name)
126+
} else {
127+
goodClients = append(goodClients, t.getClientInfo(client, syncStatus))
114128
}
115129
}
116130

117-
t.logger.Infof("Check result: %v, Failed Clients: %v", allResultsPass, failedClients)
131+
t.logger.Infof("Check result: %v, Failed Clients: %v", allResultsPass, failedClientNames)
132+
133+
if goodClientsData, err := vars.GeneralizeData(goodClients); err == nil {
134+
t.ctx.Outputs.SetVar("goodClients", goodClientsData)
135+
} else {
136+
t.logger.Warnf("Failed setting `goodClients` output: %v", err)
137+
}
138+
139+
if failedClientsData, err := vars.GeneralizeData(failedClients); err == nil {
140+
t.ctx.Outputs.SetVar("failedClients", failedClientsData)
141+
} else {
142+
t.logger.Warnf("Failed setting `failedClients` output: %v", err)
143+
}
118144

119145
if allResultsPass {
120146
t.ctx.SetResult(types.TaskResultSuccess)
@@ -162,3 +188,15 @@ func (t *Task) processClientCheck(client *clients.PoolClient, syncStatus *rpc.Sy
162188

163189
return true
164190
}
191+
192+
func (t *Task) getClientInfo(client *clients.PoolClient, syncStatus *rpc.SyncStatus) *ClientInfo {
193+
clientInfo := &ClientInfo{
194+
Name: client.Config.Name,
195+
Synchronizing: syncStatus.IsSyncing,
196+
Optimistic: syncStatus.IsOptimistic,
197+
SyncHead: syncStatus.HeadSlot,
198+
SyncDistance: syncStatus.SyncDistance,
199+
}
200+
201+
return clientInfo
202+
}

pkg/coordinator/tasks/check_execution_sync_status/task.go

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"github.com/ethpandaops/assertoor/pkg/coordinator/clients"
99
"github.com/ethpandaops/assertoor/pkg/coordinator/clients/execution/rpc"
1010
"github.com/ethpandaops/assertoor/pkg/coordinator/types"
11+
"github.com/ethpandaops/assertoor/pkg/coordinator/vars"
1112
"github.com/sirupsen/logrus"
1213
)
1314

@@ -29,6 +30,13 @@ type Task struct {
2930
firstHeight map[uint16]uint64
3031
}
3132

33+
type ClientInfo struct {
34+
Name string `json:"name"`
35+
Synchronizing bool `json:"synchronizing"`
36+
SyncHead uint64 `json:"syncHead"`
37+
SyncDistance uint64 `json:"syncDistance"`
38+
}
39+
3240
func NewTask(ctx *types.TaskContext, options *types.TaskOptions) (types.Task, error) {
3341
return &Task{
3442
ctx: ctx,
@@ -87,7 +95,9 @@ func (t *Task) Execute(ctx context.Context) error {
8795

8896
func (t *Task) processCheck(ctx context.Context) {
8997
allResultsPass := true
90-
failedClients := []string{}
98+
goodClients := []*ClientInfo{}
99+
failedClients := []*ClientInfo{}
100+
failedClientNames := []string{}
91101

92102
for _, client := range t.ctx.Scheduler.GetServices().ClientPool().GetClientsByNamePatterns(t.config.ClientPattern, "") {
93103
var checkResult bool
@@ -110,11 +120,26 @@ func (t *Task) processCheck(ctx context.Context) {
110120
if !checkResult {
111121
allResultsPass = false
112122

113-
failedClients = append(failedClients, client.Config.Name)
123+
failedClients = append(failedClients, t.getClientInfo(client, syncStatus))
124+
failedClientNames = append(failedClientNames, client.Config.Name)
125+
} else {
126+
goodClients = append(goodClients, t.getClientInfo(client, syncStatus))
114127
}
115128
}
116129

117-
t.logger.Infof("Check result: %v, Failed Clients: %v", allResultsPass, failedClients)
130+
t.logger.Infof("Check result: %v, Failed Clients: %v", allResultsPass, failedClientNames)
131+
132+
if goodClientsData, err := vars.GeneralizeData(goodClients); err == nil {
133+
t.ctx.Outputs.SetVar("goodClients", goodClientsData)
134+
} else {
135+
t.logger.Warnf("Failed setting `goodClients` output: %v", err)
136+
}
137+
138+
if failedClientsData, err := vars.GeneralizeData(failedClients); err == nil {
139+
t.ctx.Outputs.SetVar("failedClients", failedClientsData)
140+
} else {
141+
t.logger.Warnf("Failed setting `failedClients` output: %v", err)
142+
}
118143

119144
if allResultsPass {
120145
t.ctx.SetResult(types.TaskResultSuccess)
@@ -159,3 +184,14 @@ func (t *Task) processClientCheck(client *clients.PoolClient, syncStatus *rpc.Sy
159184

160185
return true
161186
}
187+
188+
func (t *Task) getClientInfo(client *clients.PoolClient, syncStatus *rpc.SyncStatus) *ClientInfo {
189+
clientInfo := &ClientInfo{
190+
Name: client.Config.Name,
191+
Synchronizing: syncStatus.IsSyncing,
192+
SyncHead: syncStatus.CurrentBlock,
193+
SyncDistance: syncStatus.HighestBlock - syncStatus.CurrentBlock,
194+
}
195+
196+
return clientInfo
197+
}

pkg/coordinator/tasks/generate_child_wallet/task.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88

99
"github.com/ethereum/go-ethereum/crypto"
1010
"github.com/ethpandaops/assertoor/pkg/coordinator/types"
11+
"github.com/ethpandaops/assertoor/pkg/coordinator/vars"
1112
"github.com/ethpandaops/assertoor/pkg/coordinator/wallet"
1213
"github.com/sirupsen/logrus"
1314
)
@@ -109,6 +110,13 @@ func (t *Task) Execute(ctx context.Context) error {
109110
childWallet := walletPool.GetNextChildWallet()
110111
t.logger.Infof("child wallet: %v [nonce: %v] %v ETH", childWallet.GetAddress().Hex(), childWallet.GetNonce(), childWallet.GetReadableBalance(18, 0, 4, false, false))
111112

113+
walletSummary := childWallet.GetSummary()
114+
if walletSummaryData, err := vars.GeneralizeData(walletSummary); err == nil {
115+
t.ctx.Outputs.SetVar("childWallet", walletSummaryData)
116+
} else {
117+
t.logger.Warnf("Failed setting `childWallet` output: %v", err)
118+
}
119+
112120
if t.config.WalletAddressResultVar != "" {
113121
t.ctx.Vars.SetVar(t.config.WalletAddressResultVar, childWallet.GetAddress().Hex())
114122
}

pkg/coordinator/tasks/generate_deposits/task.go

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -204,41 +204,47 @@ func (t *Task) Execute(ctx context.Context) error {
204204
t.ctx.Vars.SetVar(t.config.ValidatorPubkeysResultVar, validatorPubkeys)
205205
}
206206

207+
t.ctx.Outputs.SetVar("validatorPubkeys", validatorPubkeys)
208+
207209
if t.config.DepositTransactionsResultVar != "" {
208210
t.ctx.Vars.SetVar(t.config.DepositTransactionsResultVar, depositTransactions)
209211
}
210212

211-
if t.config.DepositReceiptsResultVar != "" {
212-
receiptList := []interface{}{}
213+
t.ctx.Outputs.SetVar("depositTransactions", depositTransactions)
213214

214-
for _, txhash := range depositTransactions {
215-
var receiptMap map[string]interface{}
215+
receiptList := []interface{}{}
216216

217-
receipt := depositReceipts[txhash]
218-
if receipt == nil {
219-
receiptMap = nil
220-
} else {
221-
receiptJSON, err := json.Marshal(receipt)
222-
if err == nil {
223-
receiptMap = map[string]interface{}{}
224-
err = json.Unmarshal(receiptJSON, &receiptMap)
225-
226-
if err != nil {
227-
t.logger.Errorf("could not unmarshal transaction receipt for result var: %v", err)
228-
229-
receiptMap = nil
230-
}
231-
} else {
232-
t.logger.Errorf("could not marshal transaction receipt for result var: %v", err)
217+
for _, txhash := range depositTransactions {
218+
var receiptMap map[string]interface{}
219+
220+
receipt := depositReceipts[txhash]
221+
if receipt == nil {
222+
receiptMap = nil
223+
} else {
224+
receiptJSON, err := json.Marshal(receipt)
225+
if err == nil {
226+
receiptMap = map[string]interface{}{}
227+
err = json.Unmarshal(receiptJSON, &receiptMap)
228+
229+
if err != nil {
230+
t.logger.Errorf("could not unmarshal transaction receipt for result var: %v", err)
231+
232+
receiptMap = nil
233233
}
234+
} else {
235+
t.logger.Errorf("could not marshal transaction receipt for result var: %v", err)
234236
}
235-
236-
receiptList = append(receiptList, receiptMap)
237237
}
238238

239+
receiptList = append(receiptList, receiptMap)
240+
}
241+
242+
if t.config.DepositReceiptsResultVar != "" {
239243
t.ctx.Vars.SetVar(t.config.DepositReceiptsResultVar, receiptList)
240244
}
241245

246+
t.ctx.Outputs.SetVar("depositReceipts", receiptList)
247+
242248
if t.config.FailOnReject {
243249
for _, txhash := range depositTransactions {
244250
if depositReceipts[txhash] == nil {

pkg/coordinator/tasks/generate_random_mnemonic/task.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,5 +86,7 @@ func (t *Task) Execute(_ context.Context) error {
8686
t.ctx.Vars.SetVar(t.config.MnemonicResultVar, mnemonic)
8787
}
8888

89+
t.ctx.Outputs.SetVar("mnemonic", mnemonic)
90+
8991
return nil
9092
}

pkg/coordinator/tasks/generate_transaction/task.go

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"bytes"
55
"context"
66
"crypto/rand"
7-
"encoding/json"
87
"fmt"
98
"math/big"
109
"strings"
@@ -16,6 +15,7 @@ import (
1615
"github.com/ethereum/go-ethereum/crypto"
1716
"github.com/ethpandaops/assertoor/pkg/coordinator/clients/execution"
1817
"github.com/ethpandaops/assertoor/pkg/coordinator/types"
18+
"github.com/ethpandaops/assertoor/pkg/coordinator/vars"
1919
"github.com/ethpandaops/assertoor/pkg/coordinator/wallet"
2020
"github.com/ethpandaops/assertoor/pkg/coordinator/wallet/blobtx"
2121
"github.com/holiman/uint256"
@@ -167,6 +167,8 @@ func (t *Task) Execute(ctx context.Context) error {
167167
t.ctx.Vars.SetVar(t.config.TransactionHashResultVar, tx.Hash().Hex())
168168
}
169169

170+
t.ctx.Outputs.SetVar("transactionHash", tx.Hash().Hex())
171+
170172
if t.config.AwaitReceipt {
171173
receipt, err := t.wallet.AwaitTransaction(ctx, tx)
172174
if err != nil {
@@ -192,20 +194,16 @@ func (t *Task) Execute(ctx context.Context) error {
192194
t.ctx.Vars.SetVar(t.config.ContractAddressResultVar, receipt.ContractAddress.Hex())
193195
}
194196

195-
if t.config.TransactionReceiptResultVar != "" {
196-
receiptJSON, err := json.Marshal(receipt)
197-
if err == nil {
198-
receiptMap := map[string]interface{}{}
199-
err = json.Unmarshal(receiptJSON, &receiptMap)
197+
t.ctx.Outputs.SetVar("contractAddress", receipt.ContractAddress.Hex())
200198

201-
if err == nil {
202-
t.ctx.Vars.SetVar(t.config.TransactionReceiptResultVar, receiptMap)
203-
} else {
204-
t.logger.Errorf("could not unmarshal transaction receipt for result var: %v", err)
205-
}
206-
} else {
207-
t.logger.Errorf("could not marshal transaction receipt for result var: %v", err)
199+
if receiptData, err := vars.GeneralizeData(receipt); err == nil {
200+
t.ctx.Outputs.SetVar("receipt", receiptData)
201+
202+
if t.config.TransactionReceiptResultVar != "" {
203+
t.ctx.Vars.SetVar(t.config.TransactionReceiptResultVar, receiptData)
208204
}
205+
} else {
206+
t.logger.Warnf("Failed setting `receipt` output: %v", err)
209207
}
210208

211209
if len(t.config.ExpectEvents) > 0 {

pkg/coordinator/wallet/wallet.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"github.com/ethereum/go-ethereum/accounts/abi/bind"
1414
"github.com/ethereum/go-ethereum/common"
1515
"github.com/ethereum/go-ethereum/core/types"
16+
"github.com/ethereum/go-ethereum/crypto"
1617
"github.com/ethpandaops/assertoor/pkg/coordinator/clients/execution"
1718
"github.com/sirupsen/logrus"
1819
)
@@ -39,6 +40,15 @@ type Wallet struct {
3940
txNonceMutex sync.Mutex
4041
}
4142

43+
type Summary struct {
44+
Address string `json:"address"`
45+
PrivKey string `json:"privkey"`
46+
PendingBalance *big.Int `json:"pendingBalance"`
47+
PendingNonce uint64 `json:"pendingNonce"`
48+
ConfirmedBalance *big.Int `json:"confirmedBalance"`
49+
ConfirmedNonce uint64 `json:"confirmedNonce"`
50+
}
51+
4252
type nonceStatus struct {
4353
receipt *types.Receipt
4454
channel chan bool
@@ -136,6 +146,17 @@ func (wallet *Wallet) GetNonce() uint64 {
136146
return wallet.confirmedNonce
137147
}
138148

149+
func (wallet *Wallet) GetSummary() *Summary {
150+
return &Summary{
151+
Address: wallet.address.String(),
152+
PrivKey: fmt.Sprintf("%x", crypto.FromECDSA(wallet.privkey)),
153+
PendingBalance: wallet.pendingBalance,
154+
PendingNonce: wallet.pendingNonce,
155+
ConfirmedBalance: wallet.confirmedBalance,
156+
ConfirmedNonce: wallet.confirmedNonce,
157+
}
158+
}
159+
139160
func (wallet *Wallet) GetReadableBalance(unitDigits, maxPreCommaDigitsBeforeTrim, digits int, addPositiveSign, trimAmount bool) string {
140161
// Initialize trimmedAmount and postComma variables to "0"
141162
fullAmount := ""

0 commit comments

Comments
 (0)