Skip to content

Commit cce5c1d

Browse files
committed
Fix SVR forwarder (#236)
* Fix SVR forwarder * Add more logs * Safeguard logs * Add omitempty
1 parent 4e8a14d commit cce5c1d

File tree

1 file changed

+50
-8
lines changed

1 file changed

+50
-8
lines changed

pkg/txm/clientwrappers/dualbroadcast/meta_client.go

Lines changed: 50 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ type MetaClient struct {
136136

137137
func NewMetaClient(lggr logger.Logger, c MetaClientRPC, ks MetaClientKeystore, customURL *url.URL, chainID *big.Int) *MetaClient {
138138
return &MetaClient{
139-
lggr: logger.Sugared(logger.Named(lggr, "MetaClient")),
139+
lggr: logger.Sugared(logger.Named(lggr, "Txm.Txm.MetaClient")),
140140
c: c,
141141
ks: ks,
142142
customURL: customURL,
@@ -159,7 +159,7 @@ func (a *MetaClient) SendTransaction(ctx context.Context, tx *types.Transaction,
159159
}
160160

161161
if meta != nil && meta.DualBroadcast != nil && *meta.DualBroadcast && !tx.IsPurgeable && meta.DualBroadcastParams != nil && meta.FwdrDestAddress != nil {
162-
meta, err := a.SendRequest(ctx, tx, attempt, *meta.DualBroadcastParams, *meta.FwdrDestAddress)
162+
meta, err := a.SendRequest(ctx, tx, attempt, *meta.DualBroadcastParams, tx.ToAddress)
163163
if err != nil {
164164
return fmt.Errorf("error sending request for transactionID(%d): %w", tx.ID, err)
165165
}
@@ -169,9 +169,10 @@ func (a *MetaClient) SendTransaction(ctx context.Context, tx *types.Transaction,
169169
}
170170
return nil
171171
}
172-
a.lggr.Info("No bids for transactionID(%d): ", tx.ID)
172+
a.lggr.Infof("No bids for transactionID(%d): ", tx.ID)
173173
return nil
174174
}
175+
a.lggr.Infow("Broadcasting attempt to public mempool", "tx", tx)
175176
return a.c.SendTransaction(ctx, attempt.SignedTransaction)
176177
}
177178

@@ -193,6 +194,9 @@ type RequestResponse struct {
193194
}
194195

195196
type ResponseResult struct {
197+
UO *UORaw `json:"userOperation,omitempty"`
198+
SOS []*SO `json:"solverOperations,omitempty"`
199+
DO *DO `json:"dAppOperation,omitempty"`
196200
MetacalldataResponse
197201
}
198202

@@ -211,15 +215,49 @@ type UO struct {
211215
Data []byte
212216
}
213217

218+
type UORaw struct {
219+
From common.Address `json:"from"`
220+
To common.Address `json:"to"`
221+
Value *hexutil.Big `json:"value"`
222+
Gas *hexutil.Big `json:"gas"`
223+
MaxFeePerGas *hexutil.Big `json:"maxFeePerGas"`
224+
Nonce *hexutil.Big `json:"nonce"`
225+
Deadline *hexutil.Big `json:"deadline"`
226+
Dapp common.Address `json:"dapp"`
227+
Control common.Address `json:"control"`
228+
CallConfig *hexutil.Big `json:"callConfig"`
229+
DappGasLimit *hexutil.Big `json:"dappGasLimit,omitempty"`
230+
SessionKey common.Address `json:"sessionKey"`
231+
Data hexutil.Bytes `json:"data"`
232+
Signature hexutil.Bytes `json:"signature"`
233+
}
234+
214235
type SO struct {
215-
To common.Address
216-
Control common.Address
236+
From common.Address `json:"from"`
237+
To common.Address `json:"to"`
238+
Value *hexutil.Big `json:"value"`
239+
Gas *hexutil.Big `json:"gas"`
240+
MaxFeePerGas *hexutil.Big `json:"maxFeePerGas"`
241+
Deadline *hexutil.Big `json:"deadline"`
242+
Solver common.Address `json:"solver"`
243+
Control common.Address `json:"control"`
244+
UserOpHash common.Hash `json:"userOpHash"`
245+
BidToken common.Address `json:"bidToken"`
246+
BidAmount *hexutil.Big `json:"bidAmount"`
247+
Data hexutil.Bytes `json:"data"`
248+
Signature hexutil.Bytes `json:"signature"`
217249
}
218250

219251
type DO struct {
220-
To common.Address
221-
Control common.Address
222-
Bundler common.Address
252+
From common.Address `json:"from"`
253+
To common.Address `json:"to"`
254+
Nonce *hexutil.Big `json:"nonce"`
255+
Deadline *hexutil.Big `json:"deadline"`
256+
Control common.Address `json:"control"`
257+
Bundler common.Address `json:"bundler"`
258+
UserOpHash common.Hash `json:"userOpHash"`
259+
CallChainHash common.Hash `json:"callChainHash"`
260+
Signature hexutil.Bytes `json:"signature"`
223261
}
224262

225263
type Metacalldata struct {
@@ -309,6 +347,10 @@ func (a *MetaClient) SendRequest(parentCtx context.Context, tx *types.Transactio
309347
return nil, nil
310348
}
311349

350+
if r, err := json.MarshalIndent(response.Result, "", " "); err == nil {
351+
a.lggr.Info("Response: ", string(r))
352+
}
353+
312354
return VerifyResponse(response.Result.MetacalldataResponse, dualBroadcastParams, tx.Data, tx.FromAddress, fwdrDestAddress)
313355
}
314356

0 commit comments

Comments
 (0)