Skip to content

Commit

Permalink
remove old code
Browse files Browse the repository at this point in the history
Signed-off-by: Daisuke Kanda <[email protected]>
  • Loading branch information
dai1975 committed Jul 8, 2024
1 parent 2d44b48 commit 71b4f26
Showing 1 changed file with 0 additions and 137 deletions.
137 changes: 0 additions & 137 deletions pkg/relay/ethereum/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -504,143 +504,6 @@ func (iter *CallIter) sendSingleTx(ctx context.Context, c *Chain) (*gethtypes.Tr
return tx, nil
}

/*
func (iter *CallIter) sendMultiTx(ctx context.Context, c *Chain) (*gethtypes.Transaction, error) {
from := iter.Cursor()
if (iter.End()) {
return nil, nil
}
// now iter.cursor < len(iter.msgs)
logger := c.GetChainLogger()
opts, err := c.TxOpts(ctx, true);
if err != nil {
if err != nil {
return nil, err
}
}
if iter.txs == nil { // create txs at first multicall call
opts.GasLimit = math.MaxUint64
opts.NoSend = true
txs := make([]gethtypes.Transaction, 0, len(iter.msgs))
for i := 0; i < len(iter.msgs); i++ {
tx, err := c.SendTx(opts, iter.msgs[i], iter.skipUpdateClientCommitment)
if err != nil {
logger := &log.RelayLogger{Logger: logger.With(
logAttrMsgIndexFrom, i,
logAttrMsgIndexTo, i,
logAttrMsgType, fmt.Sprintf("%T", iter.msgs[i]),
)}
logger.Error("failed to build tx for gas estimation", err)
return nil, err
}
if tx.To() == nil {
err2 := fmt.Errorf("no target address")
logger.Error("failed to construct Multicall3Call", err2)
return nil, err2
}
txs = append(txs, *tx)
}
iter.txs = txs
}
var (
lastOkRawTxData string
lastOkCalls []multicall3.Multicall3Call
lastOkGasLimit uint64
)
lastOkIndex := len(iter.msgs) // it means undefined
lastNgIndex := len(iter.msgs) // it means undefined
L1:
for true {
var index int
fmt.Printf("for: msgs=%d, lastOk=%d, lastNg=%d\n", len(iter.msgs), lastOkIndex,lastNgIndex)
if lastNgIndex == len(iter.msgs) {
// note that 0 < len(iter.msgs)
index = len(iter.msgs) - 1
if lastOkIndex == index {
break
}
} else if lastOkIndex == len(iter.msgs) {
// note that lastNgIndex != from
index = (lastNgIndex - from) / 2
} else if lastOkIndex + 1 == lastNgIndex {
break
} else {
index = (lastNgIndex - lastOkIndex) / 2
}
fmt.Printf("for: index=%d\n", index)
logger := &log.RelayLogger{Logger: logger.With(
logAttrMsgIndexFrom, from,
logAttrMsgIndexTo, index,
logAttrMsgType, fmt.Sprintf("%T", iter.msgs[index]),
)}
opts.GasLimit = math.MaxUint64
opts.NoSend = true
calls := make([]multicall3.Multicall3Call, 0, len(iter.msgs))
for i := from; i <= index; i++ {
calls = append(calls, multicall3.Multicall3Call{
Target: *iter.txs[i].To(),
CallData: iter.txs[i].Data(),
})
}
multiTx, err := c.multicall3.Aggregate(opts, calls)
if err != nil {
if index == from {
logger.Error("failed to call Multicall3.Aggregate", err)
return nil, err
} else {
lastNgIndex = index
continue L1
}
}
if rawTxData, err := multiTx.MarshalBinary(); err != nil {
logger.Error("failed to encode multiTx", err)
} else {
lastOkRawTxData = hex.EncodeToString(rawTxData)
logger.Logger = logger.With(logAttrRawTxData, lastOkRawTxData)
}
txGasLimit, isBreak, err := estimateGas(ctx, c, multiTx, from < index, logger)
if err != nil {
return nil, err
}
if isBreak { // tx is fail or gas overs limit and 0 < len(calls)
lastNgIndex = index
break
}
// this calls is ok. save it and try to include next call
lastOkIndex = index
lastOkCalls = calls
lastOkGasLimit = txGasLimit
iter.Next()
}
logger = &log.RelayLogger{Logger: logger.With(
logAttrMsgIndexFrom, from,
logAttrMsgIndexTo, lastOkIndex,
logAttrRawTxData, lastOkRawTxData,
)}
opts.GasLimit = min(lastOkGasLimit, c.Config().MaxGasLimit)
opts.NoSend = false
tx, err := c.multicall3.Aggregate(opts, lastOkCalls)
if err != nil {
logger.Error("failed to send msg", err)
return nil, err
}
iter.cursor = lastOkIndex + 1
return tx, nil
}
*/

func (iter *CallIter) sendMultiTx(ctx context.Context, c *Chain) (*gethtypes.Transaction, error) {
if (iter.End()) {
return nil, nil
Expand Down

0 comments on commit 71b4f26

Please sign in to comment.