Commit 13d9396e authored by vicotor's avatar vicotor

add withdrawal in op-proposer

parent 4af57f5f
......@@ -59,6 +59,10 @@ func (e *ExChainAPI) WithdrawalProof(ctx context.Context, txHash common.Hash) (*
wblk := wrapper.NewBlkWrapper(block)
var res = &eth.WithdrawalProof{}
tx, _ := e.chain.GetTransaction(txHash)
wtx := tx.GetWithdrawTx()
if wtx == nil {
return nil, errors.New("transaction is not withdrawal tx")
}
receipt := e.chain.GetReceipt(txHash)
if receipt == nil {
return nil, errors.New("not found tx receipt")
......@@ -67,7 +71,7 @@ func (e *ExChainAPI) WithdrawalProof(ctx context.Context, txHash common.Hash) (*
if err != nil {
return nil, err
}
item := wrapper.NewTxWrapper(tx).WithdrawlHash()
item := wrapper.NewTxWrapper(tx).WithdrawalHash()
proof, err := tree.MerkleProof(item.Bytes())
if err != nil {
return nil, errors.New(fmt.Sprintf("failed to get proof (%s)", err.Error()))
......@@ -76,15 +80,37 @@ func (e *ExChainAPI) WithdrawalProof(ctx context.Context, txHash common.Hash) (*
for i, p := range proof {
copy(res.Proof[i][:], p[:])
}
res.Value = new(big.Int).SetBytes(wtx.Amount)
res.User = common.BytesToAddress(wtx.User)
res.Coin = []byte(wtx.Coin)
oo, err := e.OutputV0AtBlock(ctx, wblk.Hash())
if err != nil {
log.WithField("error", err).Error("failed to get output for withdrawal proof")
return nil, err
}
res.Output = *oo
return res, nil
}
func (e *ExChainAPI) WithdrawalTxs(ctx context.Context, blockNum uint64) ([]common.Hash, error) {
block := e.chain.GetBlock(uint256.NewInt(blockNum))
if block == nil {
return nil, errors.New("block not found in exchain")
}
wblk := wrapper.NewBlkWrapper(block)
txHashes := make([]common.Hash, 0)
for _, tx := range wblk.Transactions() {
wtx := wrapper.NewTxWrapper(tx)
if tx.TxType == nebulav1.TxType_WithdrawTx {
txHashes = append(txHashes, wtx.Hash())
}
}
return txHashes, nil
}
func (e *ExChainAPI) OutputV0AtBlock(ctx context.Context, blockHash common.Hash) (*eth.OutputV0, error) {
blk := e.chain.BlockByHash(blockHash)
if blk == nil {
......
......@@ -115,7 +115,7 @@ func (s *server) GetWithdrawalProof(ctx context.Context, request *nodev1.Withdra
if err != nil {
return nil, err
}
item := wrapper.NewTxWrapper(tx).WithdrawlHash()
item := wrapper.NewTxWrapper(tx).WithdrawalHash()
proof, err := tree.MerkleProof(item.Bytes())
if err != nil {
return nil, errors.New(fmt.Sprintf("failed to get proof (%s)", err.Error()))
......
......@@ -717,6 +717,7 @@ type LimitOrderTransaction struct {
Side OrderSide `protobuf:"varint,2,opt,name=side,proto3,enum=exchain.nebula.v1.OrderSide" json:"side,omitempty"`
Price []byte `protobuf:"bytes,3,opt,name=price,proto3" json:"price,omitempty"`
Quantity []byte `protobuf:"bytes,4,opt,name=quantity,proto3" json:"quantity,omitempty"`
OrderId string `protobuf:"bytes,5,opt,name=order_id,json=orderId,proto3" json:"order_id,omitempty"`
}
func (x *LimitOrderTransaction) Reset() {
......@@ -779,6 +780,13 @@ func (x *LimitOrderTransaction) GetQuantity() []byte {
return nil
}
func (x *LimitOrderTransaction) GetOrderId() string {
if x != nil {
return x.OrderId
}
return ""
}
type MarketOrderTransaction struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
......@@ -787,6 +795,7 @@ type MarketOrderTransaction struct {
Pair string `protobuf:"bytes,1,opt,name=pair,proto3" json:"pair,omitempty"`
Side OrderSide `protobuf:"varint,2,opt,name=side,proto3,enum=exchain.nebula.v1.OrderSide" json:"side,omitempty"`
Quantity []byte `protobuf:"bytes,3,opt,name=quantity,proto3" json:"quantity,omitempty"`
OrderId string `protobuf:"bytes,4,opt,name=order_id,json=orderId,proto3" json:"order_id,omitempty"`
}
func (x *MarketOrderTransaction) Reset() {
......@@ -842,12 +851,20 @@ func (x *MarketOrderTransaction) GetQuantity() []byte {
return nil
}
func (x *MarketOrderTransaction) GetOrderId() string {
if x != nil {
return x.OrderId
}
return ""
}
type CancelOrderTransaction struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
OrderId string `protobuf:"bytes,1,opt,name=order_id,json=orderId,proto3" json:"order_id,omitempty"`
Pair string `protobuf:"bytes,2,opt,name=pair,proto3" json:"pair,omitempty"`
}
func (x *CancelOrderTransaction) Reset() {
......@@ -889,6 +906,13 @@ func (x *CancelOrderTransaction) GetOrderId() string {
return ""
}
func (x *CancelOrderTransaction) GetPair() string {
if x != nil {
return x.Pair
}
return ""
}
type ProtocolTransaction struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
......@@ -1077,7 +1101,7 @@ var file_nebula_v1_transaction_proto_rawDesc = []byte{
0x44, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x50, 0x61, 0x69, 0x72, 0x54, 0x72, 0x61, 0x6e, 0x73,
0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1b, 0x0a, 0x09, 0x70, 0x61, 0x69, 0x72, 0x5f, 0x6e,
0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x61, 0x69, 0x72, 0x4e,
0x61, 0x6d, 0x65, 0x22, 0x8f, 0x01, 0x0a, 0x15, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x4f, 0x72, 0x64,
0x61, 0x6d, 0x65, 0x22, 0xaa, 0x01, 0x0a, 0x15, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x4f, 0x72, 0x64,
0x65, 0x72, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a,
0x04, 0x70, 0x61, 0x69, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x61, 0x69,
0x72, 0x12, 0x30, 0x0a, 0x04, 0x73, 0x69, 0x64, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32,
......@@ -1086,54 +1110,58 @@ var file_nebula_v1_transaction_proto_rawDesc = []byte{
0x69, 0x64, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x70, 0x72, 0x69, 0x63, 0x65, 0x18, 0x03, 0x20, 0x01,
0x28, 0x0c, 0x52, 0x05, 0x70, 0x72, 0x69, 0x63, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x71, 0x75, 0x61,
0x6e, 0x74, 0x69, 0x74, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x08, 0x71, 0x75, 0x61,
0x6e, 0x74, 0x69, 0x74, 0x79, 0x22, 0x7a, 0x0a, 0x16, 0x4d, 0x61, 0x72, 0x6b, 0x65, 0x74, 0x4f,
0x72, 0x64, 0x65, 0x72, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12,
0x12, 0x0a, 0x04, 0x70, 0x61, 0x69, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x70,
0x61, 0x69, 0x72, 0x12, 0x30, 0x0a, 0x04, 0x73, 0x69, 0x64, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28,
0x0e, 0x32, 0x1c, 0x2e, 0x65, 0x78, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x2e, 0x6e, 0x65, 0x62, 0x75,
0x6c, 0x61, 0x2e, 0x76, 0x31, 0x2e, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x53, 0x69, 0x64, 0x65, 0x52,
0x04, 0x73, 0x69, 0x64, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x71, 0x75, 0x61, 0x6e, 0x74, 0x69, 0x74,
0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x08, 0x71, 0x75, 0x61, 0x6e, 0x74, 0x69, 0x74,
0x79, 0x22, 0x33, 0x0a, 0x16, 0x43, 0x61, 0x6e, 0x63, 0x65, 0x6c, 0x4f, 0x72, 0x64, 0x65, 0x72,
0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x19, 0x0a, 0x08, 0x6f,
0x72, 0x64, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6f,
0x72, 0x64, 0x65, 0x72, 0x49, 0x64, 0x22, 0xbb, 0x01, 0x0a, 0x13, 0x50, 0x72, 0x6f, 0x74, 0x6f,
0x63, 0x6f, 0x6c, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1b,
0x0a, 0x09, 0x6c, 0x31, 0x5f, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28,
0x04, 0x52, 0x08, 0x6c, 0x31, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x17, 0x0a, 0x07, 0x6c,
0x31, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x6c, 0x31,
0x54, 0x69, 0x6d, 0x65, 0x12, 0x22, 0x0a, 0x0d, 0x6c, 0x31, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b,
0x5f, 0x68, 0x61, 0x73, 0x68, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0b, 0x6c, 0x31, 0x42,
0x6c, 0x6f, 0x63, 0x6b, 0x48, 0x61, 0x73, 0x68, 0x12, 0x27, 0x0a, 0x0f, 0x73, 0x65, 0x71, 0x75,
0x65, 0x6e, 0x63, 0x65, 0x5f, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28,
0x04, 0x52, 0x0e, 0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, 0x65, 0x4e, 0x75, 0x6d, 0x62, 0x65,
0x72, 0x12, 0x21, 0x0a, 0x0c, 0x62, 0x61, 0x74, 0x63, 0x68, 0x65, 0x72, 0x5f, 0x61, 0x64, 0x64,
0x72, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0b, 0x62, 0x61, 0x74, 0x63, 0x68, 0x65, 0x72,
0x41, 0x64, 0x64, 0x72, 0x2a, 0x96, 0x01, 0x0a, 0x06, 0x54, 0x78, 0x54, 0x79, 0x70, 0x65, 0x12,
0x0f, 0x0a, 0x0b, 0x53, 0x69, 0x67, 0x6e, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x54, 0x78, 0x10, 0x00,
0x12, 0x0d, 0x0a, 0x09, 0x44, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x54, 0x78, 0x10, 0x01, 0x12,
0x0e, 0x0a, 0x0a, 0x57, 0x69, 0x74, 0x68, 0x64, 0x72, 0x61, 0x77, 0x54, 0x78, 0x10, 0x02, 0x12,
0x10, 0x0a, 0x0c, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x61, 0x69, 0x72, 0x54, 0x78, 0x10,
0x03, 0x12, 0x11, 0x0a, 0x0d, 0x44, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x50, 0x61, 0x69, 0x72,
0x54, 0x78, 0x10, 0x04, 0x12, 0x0b, 0x0a, 0x07, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x54, 0x78, 0x10,
0x05, 0x12, 0x0c, 0x0a, 0x08, 0x4d, 0x61, 0x72, 0x6b, 0x65, 0x74, 0x54, 0x78, 0x10, 0x06, 0x12,
0x0c, 0x0a, 0x08, 0x43, 0x61, 0x6e, 0x63, 0x65, 0x6c, 0x54, 0x78, 0x10, 0x07, 0x12, 0x0e, 0x0a,
0x0a, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x54, 0x78, 0x10, 0x08, 0x42, 0xd9, 0x01,
0x0a, 0x15, 0x63, 0x6f, 0x6d, 0x2e, 0x65, 0x78, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x2e, 0x6e, 0x65,
0x62, 0x75, 0x6c, 0x61, 0x2e, 0x76, 0x31, 0x42, 0x10, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63,
0x74, 0x69, 0x6f, 0x6e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x48, 0x67, 0x69, 0x74,
0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x65, 0x78, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x2f,
0x67, 0x6f, 0x2d, 0x65, 0x78, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x2f, 0x65, 0x78, 0x63, 0x68, 0x61,
0x69, 0x6e, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2f, 0x67, 0x65, 0x6e, 0x2f,
0x67, 0x6f, 0x2f, 0x6e, 0x65, 0x62, 0x75, 0x6c, 0x61, 0x2f, 0x76, 0x31, 0x3b, 0x6e, 0x65, 0x62,
0x75, 0x6c, 0x61, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x45, 0x4e, 0x58, 0xaa, 0x02, 0x11, 0x45, 0x78,
0x63, 0x68, 0x61, 0x69, 0x6e, 0x2e, 0x4e, 0x65, 0x62, 0x75, 0x6c, 0x61, 0x2e, 0x56, 0x31, 0xca,
0x02, 0x11, 0x45, 0x78, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x5c, 0x4e, 0x65, 0x62, 0x75, 0x6c, 0x61,
0x5c, 0x56, 0x31, 0xe2, 0x02, 0x1d, 0x45, 0x78, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x5c, 0x4e, 0x65,
0x62, 0x75, 0x6c, 0x61, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64,
0x61, 0x74, 0x61, 0xea, 0x02, 0x13, 0x45, 0x78, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x3a, 0x3a, 0x4e,
0x65, 0x62, 0x75, 0x6c, 0x61, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x33,
0x6e, 0x74, 0x69, 0x74, 0x79, 0x12, 0x19, 0x0a, 0x08, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x5f, 0x69,
0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x49, 0x64,
0x22, 0x95, 0x01, 0x0a, 0x16, 0x4d, 0x61, 0x72, 0x6b, 0x65, 0x74, 0x4f, 0x72, 0x64, 0x65, 0x72,
0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x70,
0x61, 0x69, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x61, 0x69, 0x72, 0x12,
0x30, 0x0a, 0x04, 0x73, 0x69, 0x64, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1c, 0x2e,
0x65, 0x78, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x2e, 0x6e, 0x65, 0x62, 0x75, 0x6c, 0x61, 0x2e, 0x76,
0x31, 0x2e, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x53, 0x69, 0x64, 0x65, 0x52, 0x04, 0x73, 0x69, 0x64,
0x65, 0x12, 0x1a, 0x0a, 0x08, 0x71, 0x75, 0x61, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x18, 0x03, 0x20,
0x01, 0x28, 0x0c, 0x52, 0x08, 0x71, 0x75, 0x61, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x12, 0x19, 0x0a,
0x08, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52,
0x07, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x49, 0x64, 0x22, 0x47, 0x0a, 0x16, 0x43, 0x61, 0x6e, 0x63,
0x65, 0x6c, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69,
0x6f, 0x6e, 0x12, 0x19, 0x0a, 0x08, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x01,
0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x49, 0x64, 0x12, 0x12, 0x0a,
0x04, 0x70, 0x61, 0x69, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x61, 0x69,
0x72, 0x22, 0xbb, 0x01, 0x0a, 0x13, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x54, 0x72,
0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1b, 0x0a, 0x09, 0x6c, 0x31, 0x5f,
0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x08, 0x6c, 0x31,
0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x17, 0x0a, 0x07, 0x6c, 0x31, 0x5f, 0x74, 0x69, 0x6d,
0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x6c, 0x31, 0x54, 0x69, 0x6d, 0x65, 0x12,
0x22, 0x0a, 0x0d, 0x6c, 0x31, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x68, 0x61, 0x73, 0x68,
0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0b, 0x6c, 0x31, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x48,
0x61, 0x73, 0x68, 0x12, 0x27, 0x0a, 0x0f, 0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, 0x65, 0x5f,
0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0e, 0x73, 0x65,
0x71, 0x75, 0x65, 0x6e, 0x63, 0x65, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x21, 0x0a, 0x0c,
0x62, 0x61, 0x74, 0x63, 0x68, 0x65, 0x72, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x18, 0x05, 0x20, 0x01,
0x28, 0x0c, 0x52, 0x0b, 0x62, 0x61, 0x74, 0x63, 0x68, 0x65, 0x72, 0x41, 0x64, 0x64, 0x72, 0x2a,
0x96, 0x01, 0x0a, 0x06, 0x54, 0x78, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0f, 0x0a, 0x0b, 0x53, 0x69,
0x67, 0x6e, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x54, 0x78, 0x10, 0x00, 0x12, 0x0d, 0x0a, 0x09, 0x44,
0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x54, 0x78, 0x10, 0x01, 0x12, 0x0e, 0x0a, 0x0a, 0x57, 0x69,
0x74, 0x68, 0x64, 0x72, 0x61, 0x77, 0x54, 0x78, 0x10, 0x02, 0x12, 0x10, 0x0a, 0x0c, 0x43, 0x72,
0x65, 0x61, 0x74, 0x65, 0x50, 0x61, 0x69, 0x72, 0x54, 0x78, 0x10, 0x03, 0x12, 0x11, 0x0a, 0x0d,
0x44, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x50, 0x61, 0x69, 0x72, 0x54, 0x78, 0x10, 0x04, 0x12,
0x0b, 0x0a, 0x07, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x54, 0x78, 0x10, 0x05, 0x12, 0x0c, 0x0a, 0x08,
0x4d, 0x61, 0x72, 0x6b, 0x65, 0x74, 0x54, 0x78, 0x10, 0x06, 0x12, 0x0c, 0x0a, 0x08, 0x43, 0x61,
0x6e, 0x63, 0x65, 0x6c, 0x54, 0x78, 0x10, 0x07, 0x12, 0x0e, 0x0a, 0x0a, 0x50, 0x72, 0x6f, 0x74,
0x6f, 0x63, 0x6f, 0x6c, 0x54, 0x78, 0x10, 0x08, 0x42, 0xd9, 0x01, 0x0a, 0x15, 0x63, 0x6f, 0x6d,
0x2e, 0x65, 0x78, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x2e, 0x6e, 0x65, 0x62, 0x75, 0x6c, 0x61, 0x2e,
0x76, 0x31, 0x42, 0x10, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x50,
0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x48, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63,
0x6f, 0x6d, 0x2f, 0x65, 0x78, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x2f, 0x67, 0x6f, 0x2d, 0x65, 0x78,
0x63, 0x68, 0x61, 0x69, 0x6e, 0x2f, 0x65, 0x78, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x2f, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x67, 0x6f, 0x2f, 0x6e, 0x65,
0x62, 0x75, 0x6c, 0x61, 0x2f, 0x76, 0x31, 0x3b, 0x6e, 0x65, 0x62, 0x75, 0x6c, 0x61, 0x76, 0x31,
0xa2, 0x02, 0x03, 0x45, 0x4e, 0x58, 0xaa, 0x02, 0x11, 0x45, 0x78, 0x63, 0x68, 0x61, 0x69, 0x6e,
0x2e, 0x4e, 0x65, 0x62, 0x75, 0x6c, 0x61, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x11, 0x45, 0x78, 0x63,
0x68, 0x61, 0x69, 0x6e, 0x5c, 0x4e, 0x65, 0x62, 0x75, 0x6c, 0x61, 0x5c, 0x56, 0x31, 0xe2, 0x02,
0x1d, 0x45, 0x78, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x5c, 0x4e, 0x65, 0x62, 0x75, 0x6c, 0x61, 0x5c,
0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02,
0x13, 0x45, 0x78, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x3a, 0x3a, 0x4e, 0x65, 0x62, 0x75, 0x6c, 0x61,
0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
......
......@@ -3,8 +3,12 @@ package wrapper
import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/rlp"
"github.com/exchain/go-exchain/exchain"
nebulav1 "github.com/exchain/go-exchain/exchain/protocol/gen/go/nebula/v1"
"github.com/golang/protobuf/proto"
log "github.com/sirupsen/logrus"
"math/big"
)
type TxWrapper struct {
......@@ -36,6 +40,29 @@ func (t *TxWrapper) calcHash() common.Hash {
}
func (t *TxWrapper) WithdrawalHash() common.Hash {
if t.tx.TxType != nebulav1.TxType_WithdrawTx {
return common.Hash{}
}
wtx := t.tx.GetWithdrawTx()
if wtx == nil {
return common.Hash{}
}
param := exchain.ExChainWithdrawalParam{
Value: new(big.Int).SetBytes(wtx.Amount),
User: common.BytesToAddress(wtx.User),
Coin: wtx.Coin,
}
// todo: vicotor check rlp encode?
data, err := rlp.EncodeToBytes(param)
if err != nil {
log.WithField("err", err).Error("rlp encode withdrawal param failed")
return common.Hash{}
}
hash := crypto.Keccak256Hash(data)
return hash
}
func (t *TxWrapper) Bytes() ([]byte, error) {
return proto.Marshal(t.tx)
}
......
......@@ -10,12 +10,12 @@ require (
github.com/btcsuite/btcd v0.24.2
github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0
github.com/cockroachdb/pebble v1.1.3
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.4.0
github.com/ethereum-optimism/go-ethereum-hdwallet v0.1.3
github.com/ethereum-optimism/superchain-registry/superchain v0.0.0-20250115145553-996c7aba6565
github.com/ethereum/go-ethereum v1.15.0
github.com/ethereum/go-ethereum v1.15.7
github.com/fsnotify/fsnotify v1.8.0
github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb
github.com/golang/snappy v1.0.0
github.com/google/go-cmp v0.6.0
github.com/google/gofuzz v1.2.1-0.20220503160820-4a35382e8fc8
github.com/hashicorp/go-multierror v1.1.1
......@@ -44,15 +44,16 @@ require (
github.com/protolambda/ctxlock v0.1.0
github.com/stretchr/testify v1.10.0
github.com/urfave/cli/v2 v2.27.5
golang.org/x/crypto v0.32.0
golang.org/x/crypto v0.36.0
golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c
golang.org/x/sync v0.10.0
golang.org/x/term v0.28.0
golang.org/x/sync v0.13.0
golang.org/x/term v0.30.0
golang.org/x/time v0.9.0
gopkg.in/yaml.v3 v3.0.1
)
require (
github.com/bwmarrin/snowflake v0.3.0 // indirect
github.com/consensys/gnark-crypto v0.12.1 // indirect
github.com/crate-crypto/go-kzg-4844 v1.0.0 // indirect
github.com/emirpasic/gods v1.18.1 // indirect
......@@ -89,7 +90,7 @@ require (
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/davidlazar/go-crypto v0.0.0-20200604182044-b73af7476f6c // indirect
github.com/deckarep/golang-set/v2 v2.6.0 // indirect
github.com/decred/dcrd/crypto/blake256 v1.0.1 // indirect
github.com/decred/dcrd/crypto/blake256 v1.1.0 // indirect
github.com/dgraph-io/ristretto v0.0.3-0.20200630154024-f66de99634de // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/dsnet/compress v0.0.2-0.20210315054119-f66993602bf5 // indirect
......@@ -106,7 +107,7 @@ require (
github.com/go-ini/ini v1.67.0 // indirect
github.com/go-ole/go-ole v1.3.0 // indirect
github.com/go-yaml/yaml v2.1.0+incompatible // indirect
github.com/goccy/go-json v0.10.3 // indirect
github.com/goccy/go-json v0.10.5 // indirect
github.com/godbus/dbus/v5 v5.1.0 // indirect
github.com/gofrs/flock v0.8.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
......@@ -123,7 +124,7 @@ require (
github.com/hashicorp/go-immutable-radix v1.0.0 // indirect
github.com/hashicorp/go-metrics v0.5.4 // indirect
github.com/hashicorp/go-msgpack/v2 v2.1.2 // indirect
github.com/hashicorp/golang-lru v0.5.0
github.com/hashicorp/golang-lru v1.0.2
github.com/hashicorp/golang-lru/arc/v2 v2.0.7 // indirect
github.com/hashicorp/raft-boltdb v0.0.0-20231211162105-6c830fa4535e // indirect
github.com/holiman/billy v0.0.0-20240216141850-2abb0c79d3c4 // indirect
......@@ -134,7 +135,7 @@ require (
github.com/jackpal/go-nat-pmp v1.0.2 // indirect
github.com/jbenet/go-temp-err-catcher v0.1.0 // indirect
github.com/jbenet/goprocess v0.1.4 // indirect
github.com/klauspost/cpuid/v2 v2.2.8 // indirect
github.com/klauspost/cpuid/v2 v2.2.10 // indirect
github.com/koron/go-ssdp v0.0.4 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/kr/text v0.2.0 // indirect
......@@ -215,14 +216,14 @@ require (
github.com/stretchr/objx v0.5.2 // indirect
github.com/supranational/blst v0.3.13 // indirect
github.com/syndtr/goleveldb v1.0.1-0.20220614013038-64ee5596c38a
github.com/tklauser/go-sysconf v0.3.12 // indirect
github.com/tklauser/numcpus v0.6.1 // indirect
github.com/tklauser/go-sysconf v0.3.15 // indirect
github.com/tklauser/numcpus v0.10.0 // indirect
github.com/tyler-smith/go-bip39 v1.1.0 // indirect
github.com/ulikunitz/xz v0.5.12 // indirect
github.com/wlynxg/anet v0.0.4 // indirect
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect
github.com/yusufpapurcu/wmi v1.2.3 // indirect
github.com/yusufpapurcu/wmi v1.2.4 // indirect
go.etcd.io/bbolt v1.3.5 // indirect
go.uber.org/dig v1.18.0 // indirect
go.uber.org/fx v1.22.2 // indirect
......@@ -230,15 +231,15 @@ require (
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.27.0 // indirect
golang.org/x/mod v0.21.0 // indirect
golang.org/x/net v0.34.0 // indirect
golang.org/x/sys v0.29.0 // indirect
golang.org/x/text v0.21.0 // indirect
golang.org/x/net v0.38.0 // indirect
golang.org/x/sys v0.32.0 // indirect
golang.org/x/text v0.24.0 // indirect
golang.org/x/tools v0.26.0 // indirect
google.golang.org/genproto v0.0.0-20230726155614-23370e0ffb3e // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20230711160842-782d3b101e98 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230803162519-f966b187b2e5 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20250115164207-1a7da9e5054f // indirect
google.golang.org/grpc v1.57.1
google.golang.org/protobuf v1.34.2
google.golang.org/protobuf v1.36.6
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
lukechampine.com/blake3 v1.3.0 // indirect
......
......@@ -83,6 +83,8 @@ github.com/btcsuite/snappy-go v1.0.0/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg
github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtEyQwv5/p4Mg4C0fgbePVuGr935/5ddU9Z3TmDRY=
github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs=
github.com/buger/jsonparser v0.0.0-20181115193947-bf1c66bbce23/go.mod h1:bbYlZJ7hK1yFx9hf58LP0zeX7UjIGs20ufpu3evjr+s=
github.com/bwmarrin/snowflake v0.3.0 h1:xm67bEhkKh6ij1790JB83OujPR5CzNe8QuQqAgISZN0=
github.com/bwmarrin/snowflake v0.3.0/go.mod h1:NdZxfVWX+oR6y2K0o6qAYv6gIOP9rjG0/E9WsDpxqwE=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/cespare/cp v0.1.0 h1:SE+dxFebS7Iik5LK0tsi1k9ZCxEaFX4AjQmoyA+1dJk=
github.com/cespare/cp v0.1.0/go.mod h1:SOGHArjBr4JWaSDEVpWpo/hNg6RoKrls6Oh40hiwW+s=
......@@ -150,11 +152,11 @@ github.com/davidlazar/go-crypto v0.0.0-20200604182044-b73af7476f6c/go.mod h1:6Uh
github.com/deckarep/golang-set/v2 v2.6.0 h1:XfcQbWM1LlMB8BsJ8N9vW5ehnnPVIw0je80NsVHagjM=
github.com/deckarep/golang-set/v2 v2.6.0/go.mod h1:VAky9rY/yGXJOLEDv3OMci+7wtDpOF4IN+y82NBOac4=
github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc=
github.com/decred/dcrd/crypto/blake256 v1.0.1 h1:7PltbUIQB7u/FfZ39+DGa/ShuMyJ5ilcvdfma9wOH6Y=
github.com/decred/dcrd/crypto/blake256 v1.0.1/go.mod h1:2OfgNZ5wDpcsFmHmCK5gZTPcCXqlm2ArzUIkw9czNJo=
github.com/decred/dcrd/crypto/blake256 v1.1.0 h1:zPMNGQCm0g4QTY27fOCorQW7EryeQ/U0x++OzVrdms8=
github.com/decred/dcrd/crypto/blake256 v1.1.0/go.mod h1:2OfgNZ5wDpcsFmHmCK5gZTPcCXqlm2ArzUIkw9czNJo=
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeCxkaw7y45JueMRL4DIyJDKs=
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 h1:rpfIENRNNilwHwZeG5+P150SMrnNEcHYvcCuK6dPZSg=
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0/go.mod h1:v57UDF4pDQJcEfFUCRop3lJL149eHGSe9Jvczhzjo/0=
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.4.0 h1:NMZiJj8QnKe1LgsbDayM4UoHwbvwDRwnI3hwNaAHRnc=
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.4.0/go.mod h1:ZXNYxsqcloTdSy/rNShjYzMhyjf0LaoftYK0p+A3h40=
github.com/decred/dcrd/lru v1.0.0/go.mod h1:mxKOwFd7lFjN2GZYsiz/ecgqR6kkYAl+0pz0tEMk218=
github.com/dgraph-io/badger v1.6.2 h1:mNw0qs90GVgGGWylh0umH5iag1j6n/PeJtNvL6KY/x8=
github.com/dgraph-io/badger v1.6.2/go.mod h1:JW2yswe3V058sS0kZ2h/AXeDSqFjxnZcRrVH//y2UQE=
......@@ -243,8 +245,8 @@ github.com/go-yaml/yaml v2.1.0+incompatible/go.mod h1:w2MrLa16VYP0jy6N7M5kHaCkaL
github.com/gobwas/httphead v0.1.0/go.mod h1:O/RXo79gxV8G+RqlR/otEwx4Q36zl9rqC5u12GKvMCM=
github.com/gobwas/pool v0.2.1/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw=
github.com/gobwas/ws v1.2.1/go.mod h1:hRKAFb8wOxFROYNsT1bqfWnhX+b5MFeJM9r2ZSwg/KY=
github.com/goccy/go-json v0.10.3 h1:KZ5WoDbxAIgm2HNbYckL0se1fHD6rz5j4ywS6ebzDqA=
github.com/goccy/go-json v0.10.3/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M=
github.com/goccy/go-json v0.10.5 h1:Fq85nIqj+gXn/S5ahsiTlK3TmC85qgirsdTP/+DeaC4=
github.com/goccy/go-json v0.10.5/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M=
github.com/godbus/dbus/v5 v5.0.3/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
github.com/godbus/dbus/v5 v5.1.0 h1:4KLkAxT3aOY8Li4FRJe/KvhoNFFxo0m6fNuFUO8QJUk=
......@@ -278,8 +280,8 @@ github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb h1:PBC98N2aIaM3XXiurYmW7fx4GZkL8feAMVq7nEjURHk=
github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/golang/snappy v1.0.0 h1:Oy607GVXHs7RtbggtPBnr2RmDArIsAefDwvrdWvRhGs=
github.com/golang/snappy v1.0.0/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
......@@ -343,8 +345,9 @@ github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9
github.com/hashicorp/go-retryablehttp v0.5.3/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs=
github.com/hashicorp/go-uuid v1.0.0 h1:RS8zrF7PhGwyNPOtxSClXXj9HA8feRnJzgnI1RJCSnM=
github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
github.com/hashicorp/golang-lru v0.5.0 h1:CL2msUPvZTLb5O648aiLNJw3hnBxN2+1Jq8rCOH9wdo=
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
github.com/hashicorp/golang-lru v1.0.2 h1:dV3g9Z/unq5DpblPpw+Oqcv4dU/1omnb4Ok8iPY6p1c=
github.com/hashicorp/golang-lru v1.0.2/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4=
github.com/hashicorp/golang-lru/arc/v2 v2.0.7 h1:QxkVTxwColcduO+LP7eJO56r2hFiG8zEbfAAzRv52KQ=
github.com/hashicorp/golang-lru/arc/v2 v2.0.7/go.mod h1:Pe7gBlGdc8clY5LJ0LpJXMt5AmgmWNH1g+oFFVUHOEc=
github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k=
......@@ -411,8 +414,8 @@ github.com/klauspost/compress v1.17.11 h1:In6xLpyWOi1+C7tXUUWv2ot1QvBjxevKAaI6IX
github.com/klauspost/compress v1.17.11/go.mod h1:pMDklpSncoRMuLFrf1W9Ss9KT+0rH90U12bZKk7uwG0=
github.com/klauspost/cpuid v1.2.0/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek=
github.com/klauspost/cpuid/v2 v2.0.1/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
github.com/klauspost/cpuid/v2 v2.2.8 h1:+StwCXwm9PdpiEkPyzBXIy+M9KUb4ODm0Zarf1kS5BM=
github.com/klauspost/cpuid/v2 v2.2.8/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws=
github.com/klauspost/cpuid/v2 v2.2.10 h1:tBs3QSyvjDyFTq3uoc/9xFpCuOsJQFNPiAhYdw2skhE=
github.com/klauspost/cpuid/v2 v2.2.10/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/koron/go-ssdp v0.0.4 h1:1IDwrghSKYM7yLf7XCzbByg2sJ/JcNOZRXS2jczTwz0=
......@@ -770,10 +773,10 @@ github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45
github.com/syndtr/goleveldb v1.0.1-0.20220614013038-64ee5596c38a h1:1ur3QoCqvE5fl+nylMaIr9PVV1w343YRDtsy+Rwu7XI=
github.com/syndtr/goleveldb v1.0.1-0.20220614013038-64ee5596c38a/go.mod h1:RRCYJbIwD5jmqPI9XoAFR0OcDxqUctll6zUj/+B4S48=
github.com/tarm/serial v0.0.0-20180830185346-98f6abe2eb07/go.mod h1:kDXzergiv9cbyO7IOYJZWg1U88JhDg3PB6klq9Hg2pA=
github.com/tklauser/go-sysconf v0.3.12 h1:0QaGUFOdQaIVdPgfITYzaTegZvdCjmYO52cSFAEVmqU=
github.com/tklauser/go-sysconf v0.3.12/go.mod h1:Ho14jnntGE1fpdOqQEEaiKRpvIavV0hSfmBq8nJbHYI=
github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+Fk=
github.com/tklauser/numcpus v0.6.1/go.mod h1:1XfjsgE2zo8GVw7POkMbHENHzVg3GzmoZ9fESEdAacY=
github.com/tklauser/go-sysconf v0.3.15 h1:VE89k0criAymJ/Os65CSn1IXaol+1wrsFHEB8Ol49K4=
github.com/tklauser/go-sysconf v0.3.15/go.mod h1:Dmjwr6tYFIseJw7a3dRLJfsHAMXZ3nEnL/aZY+0IuI4=
github.com/tklauser/numcpus v0.10.0 h1:18njr6LDBk1zuna922MgdjQuJFjrdppsZG60sHGfjso=
github.com/tklauser/numcpus v0.10.0/go.mod h1:BiTKazU708GQTYF4mB+cmlpT2Is1gLk7XVuEeem8LsQ=
github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM=
github.com/tyler-smith/go-bip39 v1.1.0 h1:5eUemwrMargf3BSLRRCalXT93Ns6pQJIjYQN2nyfOP8=
github.com/tyler-smith/go-bip39 v1.1.0/go.mod h1:gUYDtqQw1JS3ZJ8UWVcGTGqqr6YIN3CWg+kkNaLt55U=
......@@ -796,8 +799,8 @@ github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
github.com/yusufpapurcu/wmi v1.2.3 h1:E1ctvB7uKFMOJw3fdOW32DwGE9I7t++CRUEMKvFoFiw=
github.com/yusufpapurcu/wmi v1.2.3/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0=
github.com/yusufpapurcu/wmi v1.2.4 h1:zFUKzehAFReQwLys1b/iSMl+JQGSCSjtVqQn9bBrPo0=
github.com/yusufpapurcu/wmi v1.2.4/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0=
go.etcd.io/bbolt v1.3.5 h1:XAzx9gjCb0Rxj7EoqcClPD1d5ZBxZJk0jbuoPHenBt0=
go.etcd.io/bbolt v1.3.5/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ=
go.opencensus.io v0.18.0/go.mod h1:vKdFvxhtzZ9onBp9VKHK8z/sRpBMnKAsufL7wlDrCOA=
......@@ -837,8 +840,8 @@ golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5y
golang.org/x/crypto v0.8.0/go.mod h1:mRqEX+O9/h5TFCrQhkgjo2yKi0yYA+9ecGkdQoHrywE=
golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw=
golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg=
golang.org/x/crypto v0.32.0 h1:euUpcYgM8WcP71gNpTqQCn6rC2t6ULUPiOzfWaXVVfc=
golang.org/x/crypto v0.32.0/go.mod h1:ZnnJkOaASj8g0AjIduWNlq2NRxL0PlBrbKVyZ6V/Ugc=
golang.org/x/crypto v0.36.0 h1:AnAEvhDddvBdpY+uR+MyHmuZzzNqXSe/GvuDeob5L34=
golang.org/x/crypto v0.36.0/go.mod h1:Y4J0ReaxCR1IMaabaSMugxJES1EpwhBHhv2bDHklZvc=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c h1:7dEasQXItcW1xKJ2+gg5VOiBnqWrJc+rq0DPKyvvdbY=
golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c/go.mod h1:NQtJDoLvd6faHhE7m4T/1IY708gDefGGjR/iUW8yQQ8=
......@@ -890,8 +893,8 @@ golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns=
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI=
golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY=
golang.org/x/net v0.34.0 h1:Mb7Mrk043xzHgnRM88suvJFwzVrRfHEHJEl5/71CKw0=
golang.org/x/net v0.34.0/go.mod h1:di0qlW3YNM5oh6GqDGQr92MyTozJPmybPK4Ev/Gm31k=
golang.org/x/net v0.38.0 h1:vRMAPTMaeGqVhG5QyLJHqNDwecKTomGeqbnfZyKlBI8=
golang.org/x/net v0.38.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20181017192945-9dcd33a902f4/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20181203162652-d668ce993890/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
......@@ -909,8 +912,8 @@ golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJ
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ=
golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sync v0.13.0 h1:AauUjRAJ9OSnvULf/ARrrVywoJDy0YS2AwQ98I37610=
golang.org/x/sync v0.13.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
golang.org/x/sys v0.0.0-20180810173357-98c5dad5d1a0/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
......@@ -969,8 +972,8 @@ golang.org/x/sys v0.9.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU=
golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.32.0 h1:s77OFDvIQeibCmezSnk/q6iAfkdiQaJi4VzroCFrN20=
golang.org/x/sys v0.32.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
......@@ -978,8 +981,8 @@ golang.org/x/term v0.7.0/go.mod h1:P32HKFT3hSsZrRxla30E9HqToFYAQPCMs/zFMBUFqPY=
golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo=
golang.org/x/term v0.11.0/go.mod h1:zC9APTIj3jG3FdV/Ons+XE1riIZXG4aZ4GTHiPZJPIU=
golang.org/x/term v0.16.0/go.mod h1:yn7UURbUtPyrVJPGPq404EukNFxcm/foM+bV/bfcDsY=
golang.org/x/term v0.28.0 h1:/Ts8HFuMR2E6IP/jlo7QVLZHggjKQbhu/7H0LJFr3Gg=
golang.org/x/term v0.28.0/go.mod h1:Sw/lC2IAUZ92udQNf3WodGtn4k/XoLyZoh8v/8uiwek=
golang.org/x/term v0.30.0 h1:PQ39fJZ+mfadBm0y5WlL4vlM7Sx1Hgf13sMIY2+QS9Y=
golang.org/x/term v0.30.0/go.mod h1:NYYFdzHoI5wRh/h5tDMdMqCqPJZEuNqVR5xJLd/n67g=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
......@@ -990,8 +993,8 @@ golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo=
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
golang.org/x/text v0.24.0 h1:dd5Bzh4yt5KYA8f9CJHCP4FB4D51c2c6JvN37xJJkJ0=
golang.org/x/text v0.24.0/go.mod h1:L8rBsPeo2pSS+xqN0d5u2ikmjtmoJbDBT1b7nHvFCdU=
golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.9.0 h1:EsRrnYcQiGH+5FfbgvV4AP7qEZstoyrHB0DzarOQ4ZY=
......@@ -1040,8 +1043,8 @@ google.golang.org/genproto v0.0.0-20230726155614-23370e0ffb3e h1:xIXmWJ303kJCuog
google.golang.org/genproto v0.0.0-20230726155614-23370e0ffb3e/go.mod h1:0ggbjUrZYpy1q+ANUS30SEoGZ53cdfwtbuG7Ptgy108=
google.golang.org/genproto/googleapis/api v0.0.0-20230711160842-782d3b101e98 h1:FmF5cCW94Ij59cfpoLiwTgodWmm60eEV0CjlsVg2fuw=
google.golang.org/genproto/googleapis/api v0.0.0-20230711160842-782d3b101e98/go.mod h1:rsr7RhLuwsDKL7RmgDDCUc6yaGr1iqceVb5Wv6f6YvQ=
google.golang.org/genproto/googleapis/rpc v0.0.0-20230803162519-f966b187b2e5 h1:eSaPbMR4T7WfH9FvABk36NBMacoTUKdWCvV0dx+KfOg=
google.golang.org/genproto/googleapis/rpc v0.0.0-20230803162519-f966b187b2e5/go.mod h1:zBEcrKX2ZOcEkHWxBPAIvYUWOKKMIhYcmNiUIu2ji3I=
google.golang.org/genproto/googleapis/rpc v0.0.0-20250115164207-1a7da9e5054f h1:OxYkA3wjPsZyBylwymxSHa7ViiW1Sml4ToBrncvFehI=
google.golang.org/genproto/googleapis/rpc v0.0.0-20250115164207-1a7da9e5054f/go.mod h1:+2Yz8+CLJbIfL9z73EW45avw8Lmge3xVElCP9zEKi50=
google.golang.org/grpc v1.14.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw=
google.golang.org/grpc v1.16.0/go.mod h1:0JHn/cJsOMiMfNA9+DeHDlAU7KAAB5GDlYFpa9MZMio=
google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs=
......@@ -1060,8 +1063,8 @@ google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzi
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
google.golang.org/protobuf v1.36.6 h1:z1NpPI8ku2WgiWnf+t9wTPsn6eP1L7ksHUlkfLvd9xY=
google.golang.org/protobuf v1.36.6/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
......
......@@ -22,6 +22,7 @@ type l2Client interface {
//GetProof(ctx context.Context, address common.Address, storage []common.Hash, blockTag string) (*eth.AccountResult, error)
OutputV0AtBlock(ctx context.Context, blockHash common.Hash) (*eth.OutputV0, error)
WithdrawalProof(ctx context.Context, txHash common.Hash) (*eth.WithdrawalProof, error)
WithdrawalTxs(ctx context.Context, blockNumber uint64) ([]common.Hash, error)
}
type driverClient interface {
......@@ -159,6 +160,17 @@ func (n *nodeAPI) WithdrawalProof(ctx context.Context, txHash common.Hash) (*eth
return output, nil
}
func (n *nodeAPI) WithdrawalTxs(ctx context.Context, number hexutil.Uint64) ([]common.Hash, error) {
recordDur := n.m.RecordRPCServerRequest("optimism_withdrawalTxs")
defer recordDur()
output, err := n.client.WithdrawalTxs(ctx, uint64(number))
if err != nil {
return nil, fmt.Errorf("failed to get withdrawal txs at block %s: %w", number, err)
}
return output, nil
}
func (n *nodeAPI) SafeHeadAtL1Block(ctx context.Context, number hexutil.Uint64) (*eth.SafeHeadResponse, error) {
recordDur := n.m.RecordRPCServerRequest("optimism_safeHeadAtL1Block")
defer recordDur()
......
// Code generated - DO NOT EDIT.
// This file is a generated binding and any manual changes will be lost.
package bindings
import (
"errors"
"math/big"
"strings"
ethereum "github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/accounts/abi"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/event"
)
// Reference imports to suppress errors if they are not otherwise used.
var (
_ = errors.New
_ = big.NewInt
_ = strings.NewReader
_ = ethereum.NotFound
_ = bind.Bind
_ = common.Big1
_ = types.BloomLookup
_ = event.NewSubscription
)
// TypesBatchExChainWithdrawalParam is an auto generated low-level Go binding around an user-defined struct.
type TypesBatchExChainWithdrawalParam struct {
Value *big.Int
User common.Address
Coin []byte
TxHash [32]byte
WithdrawalProof [][]byte
}
// TypesExChainWithdrawalParam is an auto generated low-level Go binding around an user-defined struct.
type TypesExChainWithdrawalParam struct {
Value *big.Int
User common.Address
Coin []byte
TxHash [32]byte
}
// TypesOutputRootProof is an auto generated low-level Go binding around an user-defined struct.
type TypesOutputRootProof struct {
Version [32]byte
StateRoot [32]byte
MessagePasserStorageRoot [32]byte
LatestBlockhash [32]byte
}
// TypesWithdrawalTransaction is an auto generated low-level Go binding around an user-defined struct.
type TypesWithdrawalTransaction struct {
Nonce *big.Int
Sender common.Address
Target common.Address
Value *big.Int
GasLimit *big.Int
Data []byte
}
// PortalMetaData contains all meta data concerning the Portal contract.
var PortalMetaData = &bind.MetaData{
ABI: "[{\"type\":\"constructor\",\"inputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"receive\",\"stateMutability\":\"payable\"},{\"type\":\"function\",\"name\":\"balance\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"batchExChainWithdrawal\",\"inputs\":[{\"name\":\"_params\",\"type\":\"tuple[]\",\"internalType\":\"structTypes.BatchExChainWithdrawalParam[]\",\"components\":[{\"name\":\"value\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"user\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"coin\",\"type\":\"bytes\",\"internalType\":\"bytes\"},{\"name\":\"txHash\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"_withdrawalProof\",\"type\":\"bytes[]\",\"internalType\":\"bytes[]\"}]},{\"name\":\"_l2OutputIndex\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"_outputRootProof\",\"type\":\"tuple\",\"internalType\":\"structTypes.OutputRootProof\",\"components\":[{\"name\":\"version\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"stateRoot\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"messagePasserStorageRoot\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"latestBlockhash\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"}]}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"depositERC20Transaction\",\"inputs\":[{\"name\":\"_to\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"_mint\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"_value\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"_gasLimit\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"_isCreation\",\"type\":\"bool\",\"internalType\":\"bool\"},{\"name\":\"_data\",\"type\":\"bytes\",\"internalType\":\"bytes\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"depositTransaction\",\"inputs\":[{\"name\":\"_to\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"_value\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"_gasLimit\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"_isCreation\",\"type\":\"bool\",\"internalType\":\"bool\"},{\"name\":\"_data\",\"type\":\"bytes\",\"internalType\":\"bytes\"}],\"outputs\":[],\"stateMutability\":\"payable\"},{\"type\":\"function\",\"name\":\"donateETH\",\"inputs\":[],\"outputs\":[],\"stateMutability\":\"payable\"},{\"type\":\"function\",\"name\":\"exChainWithdrawal\",\"inputs\":[{\"name\":\"_param\",\"type\":\"tuple\",\"internalType\":\"structTypes.ExChainWithdrawalParam\",\"components\":[{\"name\":\"value\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"user\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"coin\",\"type\":\"bytes\",\"internalType\":\"bytes\"},{\"name\":\"txHash\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"}]},{\"name\":\"_l2OutputIndex\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"_outputRootProof\",\"type\":\"tuple\",\"internalType\":\"structTypes.OutputRootProof\",\"components\":[{\"name\":\"version\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"stateRoot\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"messagePasserStorageRoot\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"latestBlockhash\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"}]},{\"name\":\"_withdrawalProof\",\"type\":\"bytes[]\",\"internalType\":\"bytes[]\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"finalizeWithdrawalTransaction\",\"inputs\":[{\"name\":\"_tx\",\"type\":\"tuple\",\"internalType\":\"structTypes.WithdrawalTransaction\",\"components\":[{\"name\":\"nonce\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"sender\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"target\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"value\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"gasLimit\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"data\",\"type\":\"bytes\",\"internalType\":\"bytes\"}]}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"finalizedWithdrawals\",\"inputs\":[{\"name\":\"\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"}],\"outputs\":[{\"name\":\"\",\"type\":\"bool\",\"internalType\":\"bool\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"guardian\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"initialize\",\"inputs\":[{\"name\":\"_l2Oracle\",\"type\":\"address\",\"internalType\":\"contractL2OutputOracle\"},{\"name\":\"_systemConfig\",\"type\":\"address\",\"internalType\":\"contractSystemConfig\"},{\"name\":\"_superchainConfig\",\"type\":\"address\",\"internalType\":\"contractSuperchainConfig\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"isOutputFinalized\",\"inputs\":[{\"name\":\"_l2OutputIndex\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"outputs\":[{\"name\":\"\",\"type\":\"bool\",\"internalType\":\"bool\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"l2Oracle\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"contractL2OutputOracle\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"l2Sender\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"minimumGasLimit\",\"inputs\":[{\"name\":\"_byteCount\",\"type\":\"uint64\",\"internalType\":\"uint64\"}],\"outputs\":[{\"name\":\"\",\"type\":\"uint64\",\"internalType\":\"uint64\"}],\"stateMutability\":\"pure\"},{\"type\":\"function\",\"name\":\"params\",\"inputs\":[],\"outputs\":[{\"name\":\"prevBaseFee\",\"type\":\"uint128\",\"internalType\":\"uint128\"},{\"name\":\"prevBoughtGas\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"prevBlockNum\",\"type\":\"uint64\",\"internalType\":\"uint64\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"paused\",\"inputs\":[],\"outputs\":[{\"name\":\"paused_\",\"type\":\"bool\",\"internalType\":\"bool\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"proveWithdrawalTransaction\",\"inputs\":[{\"name\":\"_tx\",\"type\":\"tuple\",\"internalType\":\"structTypes.WithdrawalTransaction\",\"components\":[{\"name\":\"nonce\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"sender\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"target\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"value\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"gasLimit\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"data\",\"type\":\"bytes\",\"internalType\":\"bytes\"}]},{\"name\":\"_l2OutputIndex\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"_outputRootProof\",\"type\":\"tuple\",\"internalType\":\"structTypes.OutputRootProof\",\"components\":[{\"name\":\"version\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"stateRoot\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"messagePasserStorageRoot\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"latestBlockhash\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"}]},{\"name\":\"_withdrawalProof\",\"type\":\"bytes[]\",\"internalType\":\"bytes[]\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"provenWithdrawals\",\"inputs\":[{\"name\":\"\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"}],\"outputs\":[{\"name\":\"outputRoot\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"timestamp\",\"type\":\"uint128\",\"internalType\":\"uint128\"},{\"name\":\"l2OutputIndex\",\"type\":\"uint128\",\"internalType\":\"uint128\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"setGasPayingToken\",\"inputs\":[{\"name\":\"_token\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"_decimals\",\"type\":\"uint8\",\"internalType\":\"uint8\"},{\"name\":\"_name\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"_symbol\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"superchainConfig\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"contractSuperchainConfig\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"systemConfig\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"contractSystemConfig\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"version\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"string\",\"internalType\":\"string\"}],\"stateMutability\":\"pure\"},{\"type\":\"event\",\"name\":\"Initialized\",\"inputs\":[{\"name\":\"version\",\"type\":\"uint8\",\"indexed\":false,\"internalType\":\"uint8\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"TransactionDeposited\",\"inputs\":[{\"name\":\"from\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"to\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"version\",\"type\":\"uint256\",\"indexed\":true,\"internalType\":\"uint256\"},{\"name\":\"opaqueData\",\"type\":\"bytes\",\"indexed\":false,\"internalType\":\"bytes\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"WithdrawalFinalized\",\"inputs\":[{\"name\":\"withdrawalHash\",\"type\":\"bytes32\",\"indexed\":true,\"internalType\":\"bytes32\"},{\"name\":\"success\",\"type\":\"bool\",\"indexed\":false,\"internalType\":\"bool\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"WithdrawalProven\",\"inputs\":[{\"name\":\"withdrawalHash\",\"type\":\"bytes32\",\"indexed\":true,\"internalType\":\"bytes32\"},{\"name\":\"from\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"to\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"}],\"anonymous\":false},{\"type\":\"error\",\"name\":\"BadTarget\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"CallPaused\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"ContentLengthMismatch\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"EmptyItem\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"InvalidDataRemainder\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"InvalidHeader\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"LargeCalldata\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"NoValue\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"OnlyCustomGasToken\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"OutOfGas\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"SmallGasLimit\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"TransferFailed\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"Unauthorized\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"UnexpectedList\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"UnexpectedString\",\"inputs\":[]}]",
}
// PortalABI is the input ABI used to generate the binding from.
// Deprecated: Use PortalMetaData.ABI instead.
var PortalABI = PortalMetaData.ABI
// Portal is an auto generated Go binding around an Ethereum contract.
type Portal struct {
PortalCaller // Read-only binding to the contract
PortalTransactor // Write-only binding to the contract
PortalFilterer // Log filterer for contract events
}
// PortalCaller is an auto generated read-only Go binding around an Ethereum contract.
type PortalCaller struct {
contract *bind.BoundContract // Generic contract wrapper for the low level calls
}
// PortalTransactor is an auto generated write-only Go binding around an Ethereum contract.
type PortalTransactor struct {
contract *bind.BoundContract // Generic contract wrapper for the low level calls
}
// PortalFilterer is an auto generated log filtering Go binding around an Ethereum contract events.
type PortalFilterer struct {
contract *bind.BoundContract // Generic contract wrapper for the low level calls
}
// PortalSession is an auto generated Go binding around an Ethereum contract,
// with pre-set call and transact options.
type PortalSession struct {
Contract *Portal // Generic contract binding to set the session for
CallOpts bind.CallOpts // Call options to use throughout this session
TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session
}
// PortalCallerSession is an auto generated read-only Go binding around an Ethereum contract,
// with pre-set call options.
type PortalCallerSession struct {
Contract *PortalCaller // Generic contract caller binding to set the session for
CallOpts bind.CallOpts // Call options to use throughout this session
}
// PortalTransactorSession is an auto generated write-only Go binding around an Ethereum contract,
// with pre-set transact options.
type PortalTransactorSession struct {
Contract *PortalTransactor // Generic contract transactor binding to set the session for
TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session
}
// PortalRaw is an auto generated low-level Go binding around an Ethereum contract.
type PortalRaw struct {
Contract *Portal // Generic contract binding to access the raw methods on
}
// PortalCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract.
type PortalCallerRaw struct {
Contract *PortalCaller // Generic read-only contract binding to access the raw methods on
}
// PortalTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract.
type PortalTransactorRaw struct {
Contract *PortalTransactor // Generic write-only contract binding to access the raw methods on
}
// NewPortal creates a new instance of Portal, bound to a specific deployed contract.
func NewPortal(address common.Address, backend bind.ContractBackend) (*Portal, error) {
contract, err := bindPortal(address, backend, backend, backend)
if err != nil {
return nil, err
}
return &Portal{PortalCaller: PortalCaller{contract: contract}, PortalTransactor: PortalTransactor{contract: contract}, PortalFilterer: PortalFilterer{contract: contract}}, nil
}
// NewPortalCaller creates a new read-only instance of Portal, bound to a specific deployed contract.
func NewPortalCaller(address common.Address, caller bind.ContractCaller) (*PortalCaller, error) {
contract, err := bindPortal(address, caller, nil, nil)
if err != nil {
return nil, err
}
return &PortalCaller{contract: contract}, nil
}
// NewPortalTransactor creates a new write-only instance of Portal, bound to a specific deployed contract.
func NewPortalTransactor(address common.Address, transactor bind.ContractTransactor) (*PortalTransactor, error) {
contract, err := bindPortal(address, nil, transactor, nil)
if err != nil {
return nil, err
}
return &PortalTransactor{contract: contract}, nil
}
// NewPortalFilterer creates a new log filterer instance of Portal, bound to a specific deployed contract.
func NewPortalFilterer(address common.Address, filterer bind.ContractFilterer) (*PortalFilterer, error) {
contract, err := bindPortal(address, nil, nil, filterer)
if err != nil {
return nil, err
}
return &PortalFilterer{contract: contract}, nil
}
// bindPortal binds a generic wrapper to an already deployed contract.
func bindPortal(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) {
parsed, err := abi.JSON(strings.NewReader(PortalABI))
if err != nil {
return nil, err
}
return bind.NewBoundContract(address, parsed, caller, transactor, filterer), nil
}
// Call invokes the (constant) contract method with params as input values and
// sets the output to result. The result type might be a single field for simple
// returns, a slice of interfaces for anonymous returns and a struct for named
// returns.
func (_Portal *PortalRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error {
return _Portal.Contract.PortalCaller.contract.Call(opts, result, method, params...)
}
// Transfer initiates a plain transaction to move funds to the contract, calling
// its default method if one is available.
func (_Portal *PortalRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) {
return _Portal.Contract.PortalTransactor.contract.Transfer(opts)
}
// Transact invokes the (paid) contract method with params as input values.
func (_Portal *PortalRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) {
return _Portal.Contract.PortalTransactor.contract.Transact(opts, method, params...)
}
// Call invokes the (constant) contract method with params as input values and
// sets the output to result. The result type might be a single field for simple
// returns, a slice of interfaces for anonymous returns and a struct for named
// returns.
func (_Portal *PortalCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error {
return _Portal.Contract.contract.Call(opts, result, method, params...)
}
// Transfer initiates a plain transaction to move funds to the contract, calling
// its default method if one is available.
func (_Portal *PortalTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) {
return _Portal.Contract.contract.Transfer(opts)
}
// Transact invokes the (paid) contract method with params as input values.
func (_Portal *PortalTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) {
return _Portal.Contract.contract.Transact(opts, method, params...)
}
// Balance is a free data retrieval call binding the contract method 0xb69ef8a8.
//
// Solidity: function balance() view returns(uint256)
func (_Portal *PortalCaller) Balance(opts *bind.CallOpts) (*big.Int, error) {
var out []interface{}
err := _Portal.contract.Call(opts, &out, "balance")
if err != nil {
return *new(*big.Int), err
}
out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int)
return out0, err
}
// Balance is a free data retrieval call binding the contract method 0xb69ef8a8.
//
// Solidity: function balance() view returns(uint256)
func (_Portal *PortalSession) Balance() (*big.Int, error) {
return _Portal.Contract.Balance(&_Portal.CallOpts)
}
// Balance is a free data retrieval call binding the contract method 0xb69ef8a8.
//
// Solidity: function balance() view returns(uint256)
func (_Portal *PortalCallerSession) Balance() (*big.Int, error) {
return _Portal.Contract.Balance(&_Portal.CallOpts)
}
// FinalizedWithdrawals is a free data retrieval call binding the contract method 0xa14238e7.
//
// Solidity: function finalizedWithdrawals(bytes32 ) view returns(bool)
func (_Portal *PortalCaller) FinalizedWithdrawals(opts *bind.CallOpts, arg0 [32]byte) (bool, error) {
var out []interface{}
err := _Portal.contract.Call(opts, &out, "finalizedWithdrawals", arg0)
if err != nil {
return *new(bool), err
}
out0 := *abi.ConvertType(out[0], new(bool)).(*bool)
return out0, err
}
// FinalizedWithdrawals is a free data retrieval call binding the contract method 0xa14238e7.
//
// Solidity: function finalizedWithdrawals(bytes32 ) view returns(bool)
func (_Portal *PortalSession) FinalizedWithdrawals(arg0 [32]byte) (bool, error) {
return _Portal.Contract.FinalizedWithdrawals(&_Portal.CallOpts, arg0)
}
// FinalizedWithdrawals is a free data retrieval call binding the contract method 0xa14238e7.
//
// Solidity: function finalizedWithdrawals(bytes32 ) view returns(bool)
func (_Portal *PortalCallerSession) FinalizedWithdrawals(arg0 [32]byte) (bool, error) {
return _Portal.Contract.FinalizedWithdrawals(&_Portal.CallOpts, arg0)
}
// Guardian is a free data retrieval call binding the contract method 0x452a9320.
//
// Solidity: function guardian() view returns(address)
func (_Portal *PortalCaller) Guardian(opts *bind.CallOpts) (common.Address, error) {
var out []interface{}
err := _Portal.contract.Call(opts, &out, "guardian")
if err != nil {
return *new(common.Address), err
}
out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address)
return out0, err
}
// Guardian is a free data retrieval call binding the contract method 0x452a9320.
//
// Solidity: function guardian() view returns(address)
func (_Portal *PortalSession) Guardian() (common.Address, error) {
return _Portal.Contract.Guardian(&_Portal.CallOpts)
}
// Guardian is a free data retrieval call binding the contract method 0x452a9320.
//
// Solidity: function guardian() view returns(address)
func (_Portal *PortalCallerSession) Guardian() (common.Address, error) {
return _Portal.Contract.Guardian(&_Portal.CallOpts)
}
// IsOutputFinalized is a free data retrieval call binding the contract method 0x6dbffb78.
//
// Solidity: function isOutputFinalized(uint256 _l2OutputIndex) view returns(bool)
func (_Portal *PortalCaller) IsOutputFinalized(opts *bind.CallOpts, _l2OutputIndex *big.Int) (bool, error) {
var out []interface{}
err := _Portal.contract.Call(opts, &out, "isOutputFinalized", _l2OutputIndex)
if err != nil {
return *new(bool), err
}
out0 := *abi.ConvertType(out[0], new(bool)).(*bool)
return out0, err
}
// IsOutputFinalized is a free data retrieval call binding the contract method 0x6dbffb78.
//
// Solidity: function isOutputFinalized(uint256 _l2OutputIndex) view returns(bool)
func (_Portal *PortalSession) IsOutputFinalized(_l2OutputIndex *big.Int) (bool, error) {
return _Portal.Contract.IsOutputFinalized(&_Portal.CallOpts, _l2OutputIndex)
}
// IsOutputFinalized is a free data retrieval call binding the contract method 0x6dbffb78.
//
// Solidity: function isOutputFinalized(uint256 _l2OutputIndex) view returns(bool)
func (_Portal *PortalCallerSession) IsOutputFinalized(_l2OutputIndex *big.Int) (bool, error) {
return _Portal.Contract.IsOutputFinalized(&_Portal.CallOpts, _l2OutputIndex)
}
// L2Oracle is a free data retrieval call binding the contract method 0x9b5f694a.
//
// Solidity: function l2Oracle() view returns(address)
func (_Portal *PortalCaller) L2Oracle(opts *bind.CallOpts) (common.Address, error) {
var out []interface{}
err := _Portal.contract.Call(opts, &out, "l2Oracle")
if err != nil {
return *new(common.Address), err
}
out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address)
return out0, err
}
// L2Oracle is a free data retrieval call binding the contract method 0x9b5f694a.
//
// Solidity: function l2Oracle() view returns(address)
func (_Portal *PortalSession) L2Oracle() (common.Address, error) {
return _Portal.Contract.L2Oracle(&_Portal.CallOpts)
}
// L2Oracle is a free data retrieval call binding the contract method 0x9b5f694a.
//
// Solidity: function l2Oracle() view returns(address)
func (_Portal *PortalCallerSession) L2Oracle() (common.Address, error) {
return _Portal.Contract.L2Oracle(&_Portal.CallOpts)
}
// L2Sender is a free data retrieval call binding the contract method 0x9bf62d82.
//
// Solidity: function l2Sender() view returns(address)
func (_Portal *PortalCaller) L2Sender(opts *bind.CallOpts) (common.Address, error) {
var out []interface{}
err := _Portal.contract.Call(opts, &out, "l2Sender")
if err != nil {
return *new(common.Address), err
}
out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address)
return out0, err
}
// L2Sender is a free data retrieval call binding the contract method 0x9bf62d82.
//
// Solidity: function l2Sender() view returns(address)
func (_Portal *PortalSession) L2Sender() (common.Address, error) {
return _Portal.Contract.L2Sender(&_Portal.CallOpts)
}
// L2Sender is a free data retrieval call binding the contract method 0x9bf62d82.
//
// Solidity: function l2Sender() view returns(address)
func (_Portal *PortalCallerSession) L2Sender() (common.Address, error) {
return _Portal.Contract.L2Sender(&_Portal.CallOpts)
}
// MinimumGasLimit is a free data retrieval call binding the contract method 0xa35d99df.
//
// Solidity: function minimumGasLimit(uint64 _byteCount) pure returns(uint64)
func (_Portal *PortalCaller) MinimumGasLimit(opts *bind.CallOpts, _byteCount uint64) (uint64, error) {
var out []interface{}
err := _Portal.contract.Call(opts, &out, "minimumGasLimit", _byteCount)
if err != nil {
return *new(uint64), err
}
out0 := *abi.ConvertType(out[0], new(uint64)).(*uint64)
return out0, err
}
// MinimumGasLimit is a free data retrieval call binding the contract method 0xa35d99df.
//
// Solidity: function minimumGasLimit(uint64 _byteCount) pure returns(uint64)
func (_Portal *PortalSession) MinimumGasLimit(_byteCount uint64) (uint64, error) {
return _Portal.Contract.MinimumGasLimit(&_Portal.CallOpts, _byteCount)
}
// MinimumGasLimit is a free data retrieval call binding the contract method 0xa35d99df.
//
// Solidity: function minimumGasLimit(uint64 _byteCount) pure returns(uint64)
func (_Portal *PortalCallerSession) MinimumGasLimit(_byteCount uint64) (uint64, error) {
return _Portal.Contract.MinimumGasLimit(&_Portal.CallOpts, _byteCount)
}
// Params is a free data retrieval call binding the contract method 0xcff0ab96.
//
// Solidity: function params() view returns(uint128 prevBaseFee, uint64 prevBoughtGas, uint64 prevBlockNum)
func (_Portal *PortalCaller) Params(opts *bind.CallOpts) (struct {
PrevBaseFee *big.Int
PrevBoughtGas uint64
PrevBlockNum uint64
}, error) {
var out []interface{}
err := _Portal.contract.Call(opts, &out, "params")
outstruct := new(struct {
PrevBaseFee *big.Int
PrevBoughtGas uint64
PrevBlockNum uint64
})
if err != nil {
return *outstruct, err
}
outstruct.PrevBaseFee = *abi.ConvertType(out[0], new(*big.Int)).(**big.Int)
outstruct.PrevBoughtGas = *abi.ConvertType(out[1], new(uint64)).(*uint64)
outstruct.PrevBlockNum = *abi.ConvertType(out[2], new(uint64)).(*uint64)
return *outstruct, err
}
// Params is a free data retrieval call binding the contract method 0xcff0ab96.
//
// Solidity: function params() view returns(uint128 prevBaseFee, uint64 prevBoughtGas, uint64 prevBlockNum)
func (_Portal *PortalSession) Params() (struct {
PrevBaseFee *big.Int
PrevBoughtGas uint64
PrevBlockNum uint64
}, error) {
return _Portal.Contract.Params(&_Portal.CallOpts)
}
// Params is a free data retrieval call binding the contract method 0xcff0ab96.
//
// Solidity: function params() view returns(uint128 prevBaseFee, uint64 prevBoughtGas, uint64 prevBlockNum)
func (_Portal *PortalCallerSession) Params() (struct {
PrevBaseFee *big.Int
PrevBoughtGas uint64
PrevBlockNum uint64
}, error) {
return _Portal.Contract.Params(&_Portal.CallOpts)
}
// Paused is a free data retrieval call binding the contract method 0x5c975abb.
//
// Solidity: function paused() view returns(bool paused_)
func (_Portal *PortalCaller) Paused(opts *bind.CallOpts) (bool, error) {
var out []interface{}
err := _Portal.contract.Call(opts, &out, "paused")
if err != nil {
return *new(bool), err
}
out0 := *abi.ConvertType(out[0], new(bool)).(*bool)
return out0, err
}
// Paused is a free data retrieval call binding the contract method 0x5c975abb.
//
// Solidity: function paused() view returns(bool paused_)
func (_Portal *PortalSession) Paused() (bool, error) {
return _Portal.Contract.Paused(&_Portal.CallOpts)
}
// Paused is a free data retrieval call binding the contract method 0x5c975abb.
//
// Solidity: function paused() view returns(bool paused_)
func (_Portal *PortalCallerSession) Paused() (bool, error) {
return _Portal.Contract.Paused(&_Portal.CallOpts)
}
// ProvenWithdrawals is a free data retrieval call binding the contract method 0xe965084c.
//
// Solidity: function provenWithdrawals(bytes32 ) view returns(bytes32 outputRoot, uint128 timestamp, uint128 l2OutputIndex)
func (_Portal *PortalCaller) ProvenWithdrawals(opts *bind.CallOpts, arg0 [32]byte) (struct {
OutputRoot [32]byte
Timestamp *big.Int
L2OutputIndex *big.Int
}, error) {
var out []interface{}
err := _Portal.contract.Call(opts, &out, "provenWithdrawals", arg0)
outstruct := new(struct {
OutputRoot [32]byte
Timestamp *big.Int
L2OutputIndex *big.Int
})
if err != nil {
return *outstruct, err
}
outstruct.OutputRoot = *abi.ConvertType(out[0], new([32]byte)).(*[32]byte)
outstruct.Timestamp = *abi.ConvertType(out[1], new(*big.Int)).(**big.Int)
outstruct.L2OutputIndex = *abi.ConvertType(out[2], new(*big.Int)).(**big.Int)
return *outstruct, err
}
// ProvenWithdrawals is a free data retrieval call binding the contract method 0xe965084c.
//
// Solidity: function provenWithdrawals(bytes32 ) view returns(bytes32 outputRoot, uint128 timestamp, uint128 l2OutputIndex)
func (_Portal *PortalSession) ProvenWithdrawals(arg0 [32]byte) (struct {
OutputRoot [32]byte
Timestamp *big.Int
L2OutputIndex *big.Int
}, error) {
return _Portal.Contract.ProvenWithdrawals(&_Portal.CallOpts, arg0)
}
// ProvenWithdrawals is a free data retrieval call binding the contract method 0xe965084c.
//
// Solidity: function provenWithdrawals(bytes32 ) view returns(bytes32 outputRoot, uint128 timestamp, uint128 l2OutputIndex)
func (_Portal *PortalCallerSession) ProvenWithdrawals(arg0 [32]byte) (struct {
OutputRoot [32]byte
Timestamp *big.Int
L2OutputIndex *big.Int
}, error) {
return _Portal.Contract.ProvenWithdrawals(&_Portal.CallOpts, arg0)
}
// SuperchainConfig is a free data retrieval call binding the contract method 0x35e80ab3.
//
// Solidity: function superchainConfig() view returns(address)
func (_Portal *PortalCaller) SuperchainConfig(opts *bind.CallOpts) (common.Address, error) {
var out []interface{}
err := _Portal.contract.Call(opts, &out, "superchainConfig")
if err != nil {
return *new(common.Address), err
}
out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address)
return out0, err
}
// SuperchainConfig is a free data retrieval call binding the contract method 0x35e80ab3.
//
// Solidity: function superchainConfig() view returns(address)
func (_Portal *PortalSession) SuperchainConfig() (common.Address, error) {
return _Portal.Contract.SuperchainConfig(&_Portal.CallOpts)
}
// SuperchainConfig is a free data retrieval call binding the contract method 0x35e80ab3.
//
// Solidity: function superchainConfig() view returns(address)
func (_Portal *PortalCallerSession) SuperchainConfig() (common.Address, error) {
return _Portal.Contract.SuperchainConfig(&_Portal.CallOpts)
}
// SystemConfig is a free data retrieval call binding the contract method 0x33d7e2bd.
//
// Solidity: function systemConfig() view returns(address)
func (_Portal *PortalCaller) SystemConfig(opts *bind.CallOpts) (common.Address, error) {
var out []interface{}
err := _Portal.contract.Call(opts, &out, "systemConfig")
if err != nil {
return *new(common.Address), err
}
out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address)
return out0, err
}
// SystemConfig is a free data retrieval call binding the contract method 0x33d7e2bd.
//
// Solidity: function systemConfig() view returns(address)
func (_Portal *PortalSession) SystemConfig() (common.Address, error) {
return _Portal.Contract.SystemConfig(&_Portal.CallOpts)
}
// SystemConfig is a free data retrieval call binding the contract method 0x33d7e2bd.
//
// Solidity: function systemConfig() view returns(address)
func (_Portal *PortalCallerSession) SystemConfig() (common.Address, error) {
return _Portal.Contract.SystemConfig(&_Portal.CallOpts)
}
// Version is a free data retrieval call binding the contract method 0x54fd4d50.
//
// Solidity: function version() pure returns(string)
func (_Portal *PortalCaller) Version(opts *bind.CallOpts) (string, error) {
var out []interface{}
err := _Portal.contract.Call(opts, &out, "version")
if err != nil {
return *new(string), err
}
out0 := *abi.ConvertType(out[0], new(string)).(*string)
return out0, err
}
// Version is a free data retrieval call binding the contract method 0x54fd4d50.
//
// Solidity: function version() pure returns(string)
func (_Portal *PortalSession) Version() (string, error) {
return _Portal.Contract.Version(&_Portal.CallOpts)
}
// Version is a free data retrieval call binding the contract method 0x54fd4d50.
//
// Solidity: function version() pure returns(string)
func (_Portal *PortalCallerSession) Version() (string, error) {
return _Portal.Contract.Version(&_Portal.CallOpts)
}
// BatchExChainWithdrawal is a paid mutator transaction binding the contract method 0x7e34342f.
//
// Solidity: function batchExChainWithdrawal((uint256,address,bytes,bytes32,bytes[])[] _params, uint256 _l2OutputIndex, (bytes32,bytes32,bytes32,bytes32) _outputRootProof) returns()
func (_Portal *PortalTransactor) BatchExChainWithdrawal(opts *bind.TransactOpts, _params []TypesBatchExChainWithdrawalParam, _l2OutputIndex *big.Int, _outputRootProof TypesOutputRootProof) (*types.Transaction, error) {
return _Portal.contract.Transact(opts, "batchExChainWithdrawal", _params, _l2OutputIndex, _outputRootProof)
}
// BatchExChainWithdrawal is a paid mutator transaction binding the contract method 0x7e34342f.
//
// Solidity: function batchExChainWithdrawal((uint256,address,bytes,bytes32,bytes[])[] _params, uint256 _l2OutputIndex, (bytes32,bytes32,bytes32,bytes32) _outputRootProof) returns()
func (_Portal *PortalSession) BatchExChainWithdrawal(_params []TypesBatchExChainWithdrawalParam, _l2OutputIndex *big.Int, _outputRootProof TypesOutputRootProof) (*types.Transaction, error) {
return _Portal.Contract.BatchExChainWithdrawal(&_Portal.TransactOpts, _params, _l2OutputIndex, _outputRootProof)
}
// BatchExChainWithdrawal is a paid mutator transaction binding the contract method 0x7e34342f.
//
// Solidity: function batchExChainWithdrawal((uint256,address,bytes,bytes32,bytes[])[] _params, uint256 _l2OutputIndex, (bytes32,bytes32,bytes32,bytes32) _outputRootProof) returns()
func (_Portal *PortalTransactorSession) BatchExChainWithdrawal(_params []TypesBatchExChainWithdrawalParam, _l2OutputIndex *big.Int, _outputRootProof TypesOutputRootProof) (*types.Transaction, error) {
return _Portal.Contract.BatchExChainWithdrawal(&_Portal.TransactOpts, _params, _l2OutputIndex, _outputRootProof)
}
// DepositERC20Transaction is a paid mutator transaction binding the contract method 0x149f2f22.
//
// Solidity: function depositERC20Transaction(address _to, uint256 _mint, uint256 _value, uint64 _gasLimit, bool _isCreation, bytes _data) returns()
func (_Portal *PortalTransactor) DepositERC20Transaction(opts *bind.TransactOpts, _to common.Address, _mint *big.Int, _value *big.Int, _gasLimit uint64, _isCreation bool, _data []byte) (*types.Transaction, error) {
return _Portal.contract.Transact(opts, "depositERC20Transaction", _to, _mint, _value, _gasLimit, _isCreation, _data)
}
// DepositERC20Transaction is a paid mutator transaction binding the contract method 0x149f2f22.
//
// Solidity: function depositERC20Transaction(address _to, uint256 _mint, uint256 _value, uint64 _gasLimit, bool _isCreation, bytes _data) returns()
func (_Portal *PortalSession) DepositERC20Transaction(_to common.Address, _mint *big.Int, _value *big.Int, _gasLimit uint64, _isCreation bool, _data []byte) (*types.Transaction, error) {
return _Portal.Contract.DepositERC20Transaction(&_Portal.TransactOpts, _to, _mint, _value, _gasLimit, _isCreation, _data)
}
// DepositERC20Transaction is a paid mutator transaction binding the contract method 0x149f2f22.
//
// Solidity: function depositERC20Transaction(address _to, uint256 _mint, uint256 _value, uint64 _gasLimit, bool _isCreation, bytes _data) returns()
func (_Portal *PortalTransactorSession) DepositERC20Transaction(_to common.Address, _mint *big.Int, _value *big.Int, _gasLimit uint64, _isCreation bool, _data []byte) (*types.Transaction, error) {
return _Portal.Contract.DepositERC20Transaction(&_Portal.TransactOpts, _to, _mint, _value, _gasLimit, _isCreation, _data)
}
// DepositTransaction is a paid mutator transaction binding the contract method 0xe9e05c42.
//
// Solidity: function depositTransaction(address _to, uint256 _value, uint64 _gasLimit, bool _isCreation, bytes _data) payable returns()
func (_Portal *PortalTransactor) DepositTransaction(opts *bind.TransactOpts, _to common.Address, _value *big.Int, _gasLimit uint64, _isCreation bool, _data []byte) (*types.Transaction, error) {
return _Portal.contract.Transact(opts, "depositTransaction", _to, _value, _gasLimit, _isCreation, _data)
}
// DepositTransaction is a paid mutator transaction binding the contract method 0xe9e05c42.
//
// Solidity: function depositTransaction(address _to, uint256 _value, uint64 _gasLimit, bool _isCreation, bytes _data) payable returns()
func (_Portal *PortalSession) DepositTransaction(_to common.Address, _value *big.Int, _gasLimit uint64, _isCreation bool, _data []byte) (*types.Transaction, error) {
return _Portal.Contract.DepositTransaction(&_Portal.TransactOpts, _to, _value, _gasLimit, _isCreation, _data)
}
// DepositTransaction is a paid mutator transaction binding the contract method 0xe9e05c42.
//
// Solidity: function depositTransaction(address _to, uint256 _value, uint64 _gasLimit, bool _isCreation, bytes _data) payable returns()
func (_Portal *PortalTransactorSession) DepositTransaction(_to common.Address, _value *big.Int, _gasLimit uint64, _isCreation bool, _data []byte) (*types.Transaction, error) {
return _Portal.Contract.DepositTransaction(&_Portal.TransactOpts, _to, _value, _gasLimit, _isCreation, _data)
}
// DonateETH is a paid mutator transaction binding the contract method 0x8b4c40b0.
//
// Solidity: function donateETH() payable returns()
func (_Portal *PortalTransactor) DonateETH(opts *bind.TransactOpts) (*types.Transaction, error) {
return _Portal.contract.Transact(opts, "donateETH")
}
// DonateETH is a paid mutator transaction binding the contract method 0x8b4c40b0.
//
// Solidity: function donateETH() payable returns()
func (_Portal *PortalSession) DonateETH() (*types.Transaction, error) {
return _Portal.Contract.DonateETH(&_Portal.TransactOpts)
}
// DonateETH is a paid mutator transaction binding the contract method 0x8b4c40b0.
//
// Solidity: function donateETH() payable returns()
func (_Portal *PortalTransactorSession) DonateETH() (*types.Transaction, error) {
return _Portal.Contract.DonateETH(&_Portal.TransactOpts)
}
// ExChainWithdrawal is a paid mutator transaction binding the contract method 0x0bc83d91.
//
// Solidity: function exChainWithdrawal((uint256,address,bytes,bytes32) _param, uint256 _l2OutputIndex, (bytes32,bytes32,bytes32,bytes32) _outputRootProof, bytes[] _withdrawalProof) returns()
func (_Portal *PortalTransactor) ExChainWithdrawal(opts *bind.TransactOpts, _param TypesExChainWithdrawalParam, _l2OutputIndex *big.Int, _outputRootProof TypesOutputRootProof, _withdrawalProof [][]byte) (*types.Transaction, error) {
return _Portal.contract.Transact(opts, "exChainWithdrawal", _param, _l2OutputIndex, _outputRootProof, _withdrawalProof)
}
// ExChainWithdrawal is a paid mutator transaction binding the contract method 0x0bc83d91.
//
// Solidity: function exChainWithdrawal((uint256,address,bytes,bytes32) _param, uint256 _l2OutputIndex, (bytes32,bytes32,bytes32,bytes32) _outputRootProof, bytes[] _withdrawalProof) returns()
func (_Portal *PortalSession) ExChainWithdrawal(_param TypesExChainWithdrawalParam, _l2OutputIndex *big.Int, _outputRootProof TypesOutputRootProof, _withdrawalProof [][]byte) (*types.Transaction, error) {
return _Portal.Contract.ExChainWithdrawal(&_Portal.TransactOpts, _param, _l2OutputIndex, _outputRootProof, _withdrawalProof)
}
// ExChainWithdrawal is a paid mutator transaction binding the contract method 0x0bc83d91.
//
// Solidity: function exChainWithdrawal((uint256,address,bytes,bytes32) _param, uint256 _l2OutputIndex, (bytes32,bytes32,bytes32,bytes32) _outputRootProof, bytes[] _withdrawalProof) returns()
func (_Portal *PortalTransactorSession) ExChainWithdrawal(_param TypesExChainWithdrawalParam, _l2OutputIndex *big.Int, _outputRootProof TypesOutputRootProof, _withdrawalProof [][]byte) (*types.Transaction, error) {
return _Portal.Contract.ExChainWithdrawal(&_Portal.TransactOpts, _param, _l2OutputIndex, _outputRootProof, _withdrawalProof)
}
// FinalizeWithdrawalTransaction is a paid mutator transaction binding the contract method 0x8c3152e9.
//
// Solidity: function finalizeWithdrawalTransaction((uint256,address,address,uint256,uint256,bytes) _tx) returns()
func (_Portal *PortalTransactor) FinalizeWithdrawalTransaction(opts *bind.TransactOpts, _tx TypesWithdrawalTransaction) (*types.Transaction, error) {
return _Portal.contract.Transact(opts, "finalizeWithdrawalTransaction", _tx)
}
// FinalizeWithdrawalTransaction is a paid mutator transaction binding the contract method 0x8c3152e9.
//
// Solidity: function finalizeWithdrawalTransaction((uint256,address,address,uint256,uint256,bytes) _tx) returns()
func (_Portal *PortalSession) FinalizeWithdrawalTransaction(_tx TypesWithdrawalTransaction) (*types.Transaction, error) {
return _Portal.Contract.FinalizeWithdrawalTransaction(&_Portal.TransactOpts, _tx)
}
// FinalizeWithdrawalTransaction is a paid mutator transaction binding the contract method 0x8c3152e9.
//
// Solidity: function finalizeWithdrawalTransaction((uint256,address,address,uint256,uint256,bytes) _tx) returns()
func (_Portal *PortalTransactorSession) FinalizeWithdrawalTransaction(_tx TypesWithdrawalTransaction) (*types.Transaction, error) {
return _Portal.Contract.FinalizeWithdrawalTransaction(&_Portal.TransactOpts, _tx)
}
// Initialize is a paid mutator transaction binding the contract method 0xc0c53b8b.
//
// Solidity: function initialize(address _l2Oracle, address _systemConfig, address _superchainConfig) returns()
func (_Portal *PortalTransactor) Initialize(opts *bind.TransactOpts, _l2Oracle common.Address, _systemConfig common.Address, _superchainConfig common.Address) (*types.Transaction, error) {
return _Portal.contract.Transact(opts, "initialize", _l2Oracle, _systemConfig, _superchainConfig)
}
// Initialize is a paid mutator transaction binding the contract method 0xc0c53b8b.
//
// Solidity: function initialize(address _l2Oracle, address _systemConfig, address _superchainConfig) returns()
func (_Portal *PortalSession) Initialize(_l2Oracle common.Address, _systemConfig common.Address, _superchainConfig common.Address) (*types.Transaction, error) {
return _Portal.Contract.Initialize(&_Portal.TransactOpts, _l2Oracle, _systemConfig, _superchainConfig)
}
// Initialize is a paid mutator transaction binding the contract method 0xc0c53b8b.
//
// Solidity: function initialize(address _l2Oracle, address _systemConfig, address _superchainConfig) returns()
func (_Portal *PortalTransactorSession) Initialize(_l2Oracle common.Address, _systemConfig common.Address, _superchainConfig common.Address) (*types.Transaction, error) {
return _Portal.Contract.Initialize(&_Portal.TransactOpts, _l2Oracle, _systemConfig, _superchainConfig)
}
// ProveWithdrawalTransaction is a paid mutator transaction binding the contract method 0x4870496f.
//
// Solidity: function proveWithdrawalTransaction((uint256,address,address,uint256,uint256,bytes) _tx, uint256 _l2OutputIndex, (bytes32,bytes32,bytes32,bytes32) _outputRootProof, bytes[] _withdrawalProof) returns()
func (_Portal *PortalTransactor) ProveWithdrawalTransaction(opts *bind.TransactOpts, _tx TypesWithdrawalTransaction, _l2OutputIndex *big.Int, _outputRootProof TypesOutputRootProof, _withdrawalProof [][]byte) (*types.Transaction, error) {
return _Portal.contract.Transact(opts, "proveWithdrawalTransaction", _tx, _l2OutputIndex, _outputRootProof, _withdrawalProof)
}
// ProveWithdrawalTransaction is a paid mutator transaction binding the contract method 0x4870496f.
//
// Solidity: function proveWithdrawalTransaction((uint256,address,address,uint256,uint256,bytes) _tx, uint256 _l2OutputIndex, (bytes32,bytes32,bytes32,bytes32) _outputRootProof, bytes[] _withdrawalProof) returns()
func (_Portal *PortalSession) ProveWithdrawalTransaction(_tx TypesWithdrawalTransaction, _l2OutputIndex *big.Int, _outputRootProof TypesOutputRootProof, _withdrawalProof [][]byte) (*types.Transaction, error) {
return _Portal.Contract.ProveWithdrawalTransaction(&_Portal.TransactOpts, _tx, _l2OutputIndex, _outputRootProof, _withdrawalProof)
}
// ProveWithdrawalTransaction is a paid mutator transaction binding the contract method 0x4870496f.
//
// Solidity: function proveWithdrawalTransaction((uint256,address,address,uint256,uint256,bytes) _tx, uint256 _l2OutputIndex, (bytes32,bytes32,bytes32,bytes32) _outputRootProof, bytes[] _withdrawalProof) returns()
func (_Portal *PortalTransactorSession) ProveWithdrawalTransaction(_tx TypesWithdrawalTransaction, _l2OutputIndex *big.Int, _outputRootProof TypesOutputRootProof, _withdrawalProof [][]byte) (*types.Transaction, error) {
return _Portal.Contract.ProveWithdrawalTransaction(&_Portal.TransactOpts, _tx, _l2OutputIndex, _outputRootProof, _withdrawalProof)
}
// SetGasPayingToken is a paid mutator transaction binding the contract method 0x71cfaa3f.
//
// Solidity: function setGasPayingToken(address _token, uint8 _decimals, bytes32 _name, bytes32 _symbol) returns()
func (_Portal *PortalTransactor) SetGasPayingToken(opts *bind.TransactOpts, _token common.Address, _decimals uint8, _name [32]byte, _symbol [32]byte) (*types.Transaction, error) {
return _Portal.contract.Transact(opts, "setGasPayingToken", _token, _decimals, _name, _symbol)
}
// SetGasPayingToken is a paid mutator transaction binding the contract method 0x71cfaa3f.
//
// Solidity: function setGasPayingToken(address _token, uint8 _decimals, bytes32 _name, bytes32 _symbol) returns()
func (_Portal *PortalSession) SetGasPayingToken(_token common.Address, _decimals uint8, _name [32]byte, _symbol [32]byte) (*types.Transaction, error) {
return _Portal.Contract.SetGasPayingToken(&_Portal.TransactOpts, _token, _decimals, _name, _symbol)
}
// SetGasPayingToken is a paid mutator transaction binding the contract method 0x71cfaa3f.
//
// Solidity: function setGasPayingToken(address _token, uint8 _decimals, bytes32 _name, bytes32 _symbol) returns()
func (_Portal *PortalTransactorSession) SetGasPayingToken(_token common.Address, _decimals uint8, _name [32]byte, _symbol [32]byte) (*types.Transaction, error) {
return _Portal.Contract.SetGasPayingToken(&_Portal.TransactOpts, _token, _decimals, _name, _symbol)
}
// Receive is a paid mutator transaction binding the contract receive function.
//
// Solidity: receive() payable returns()
func (_Portal *PortalTransactor) Receive(opts *bind.TransactOpts) (*types.Transaction, error) {
return _Portal.contract.RawTransact(opts, nil) // calldata is disallowed for receive function
}
// Receive is a paid mutator transaction binding the contract receive function.
//
// Solidity: receive() payable returns()
func (_Portal *PortalSession) Receive() (*types.Transaction, error) {
return _Portal.Contract.Receive(&_Portal.TransactOpts)
}
// Receive is a paid mutator transaction binding the contract receive function.
//
// Solidity: receive() payable returns()
func (_Portal *PortalTransactorSession) Receive() (*types.Transaction, error) {
return _Portal.Contract.Receive(&_Portal.TransactOpts)
}
// PortalInitializedIterator is returned from FilterInitialized and is used to iterate over the raw logs and unpacked data for Initialized events raised by the Portal contract.
type PortalInitializedIterator struct {
Event *PortalInitialized // Event containing the contract specifics and raw log
contract *bind.BoundContract // Generic contract to use for unpacking event data
event string // Event name to use for unpacking event data
logs chan types.Log // Log channel receiving the found contract events
sub ethereum.Subscription // Subscription for errors, completion and termination
done bool // Whether the subscription completed delivering logs
fail error // Occurred error to stop iteration
}
// Next advances the iterator to the subsequent event, returning whether there
// are any more events found. In case of a retrieval or parsing error, false is
// returned and Error() can be queried for the exact failure.
func (it *PortalInitializedIterator) Next() bool {
// If the iterator failed, stop iterating
if it.fail != nil {
return false
}
// If the iterator completed, deliver directly whatever's available
if it.done {
select {
case log := <-it.logs:
it.Event = new(PortalInitialized)
if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil {
it.fail = err
return false
}
it.Event.Raw = log
return true
default:
return false
}
}
// Iterator still in progress, wait for either a data or an error event
select {
case log := <-it.logs:
it.Event = new(PortalInitialized)
if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil {
it.fail = err
return false
}
it.Event.Raw = log
return true
case err := <-it.sub.Err():
it.done = true
it.fail = err
return it.Next()
}
}
// Error returns any retrieval or parsing error occurred during filtering.
func (it *PortalInitializedIterator) Error() error {
return it.fail
}
// Close terminates the iteration process, releasing any pending underlying
// resources.
func (it *PortalInitializedIterator) Close() error {
it.sub.Unsubscribe()
return nil
}
// PortalInitialized represents a Initialized event raised by the Portal contract.
type PortalInitialized struct {
Version uint8
Raw types.Log // Blockchain specific contextual infos
}
// FilterInitialized is a free log retrieval operation binding the contract event 0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498.
//
// Solidity: event Initialized(uint8 version)
func (_Portal *PortalFilterer) FilterInitialized(opts *bind.FilterOpts) (*PortalInitializedIterator, error) {
logs, sub, err := _Portal.contract.FilterLogs(opts, "Initialized")
if err != nil {
return nil, err
}
return &PortalInitializedIterator{contract: _Portal.contract, event: "Initialized", logs: logs, sub: sub}, nil
}
// WatchInitialized is a free log subscription operation binding the contract event 0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498.
//
// Solidity: event Initialized(uint8 version)
func (_Portal *PortalFilterer) WatchInitialized(opts *bind.WatchOpts, sink chan<- *PortalInitialized) (event.Subscription, error) {
logs, sub, err := _Portal.contract.WatchLogs(opts, "Initialized")
if err != nil {
return nil, err
}
return event.NewSubscription(func(quit <-chan struct{}) error {
defer sub.Unsubscribe()
for {
select {
case log := <-logs:
// New log arrived, parse the event and forward to the user
event := new(PortalInitialized)
if err := _Portal.contract.UnpackLog(event, "Initialized", log); err != nil {
return err
}
event.Raw = log
select {
case sink <- event:
case err := <-sub.Err():
return err
case <-quit:
return nil
}
case err := <-sub.Err():
return err
case <-quit:
return nil
}
}
}), nil
}
// ParseInitialized is a log parse operation binding the contract event 0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498.
//
// Solidity: event Initialized(uint8 version)
func (_Portal *PortalFilterer) ParseInitialized(log types.Log) (*PortalInitialized, error) {
event := new(PortalInitialized)
if err := _Portal.contract.UnpackLog(event, "Initialized", log); err != nil {
return nil, err
}
event.Raw = log
return event, nil
}
// PortalTransactionDepositedIterator is returned from FilterTransactionDeposited and is used to iterate over the raw logs and unpacked data for TransactionDeposited events raised by the Portal contract.
type PortalTransactionDepositedIterator struct {
Event *PortalTransactionDeposited // Event containing the contract specifics and raw log
contract *bind.BoundContract // Generic contract to use for unpacking event data
event string // Event name to use for unpacking event data
logs chan types.Log // Log channel receiving the found contract events
sub ethereum.Subscription // Subscription for errors, completion and termination
done bool // Whether the subscription completed delivering logs
fail error // Occurred error to stop iteration
}
// Next advances the iterator to the subsequent event, returning whether there
// are any more events found. In case of a retrieval or parsing error, false is
// returned and Error() can be queried for the exact failure.
func (it *PortalTransactionDepositedIterator) Next() bool {
// If the iterator failed, stop iterating
if it.fail != nil {
return false
}
// If the iterator completed, deliver directly whatever's available
if it.done {
select {
case log := <-it.logs:
it.Event = new(PortalTransactionDeposited)
if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil {
it.fail = err
return false
}
it.Event.Raw = log
return true
default:
return false
}
}
// Iterator still in progress, wait for either a data or an error event
select {
case log := <-it.logs:
it.Event = new(PortalTransactionDeposited)
if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil {
it.fail = err
return false
}
it.Event.Raw = log
return true
case err := <-it.sub.Err():
it.done = true
it.fail = err
return it.Next()
}
}
// Error returns any retrieval or parsing error occurred during filtering.
func (it *PortalTransactionDepositedIterator) Error() error {
return it.fail
}
// Close terminates the iteration process, releasing any pending underlying
// resources.
func (it *PortalTransactionDepositedIterator) Close() error {
it.sub.Unsubscribe()
return nil
}
// PortalTransactionDeposited represents a TransactionDeposited event raised by the Portal contract.
type PortalTransactionDeposited struct {
From common.Address
To common.Address
Version *big.Int
OpaqueData []byte
Raw types.Log // Blockchain specific contextual infos
}
// FilterTransactionDeposited is a free log retrieval operation binding the contract event 0xb3813568d9991fc951961fcb4c784893574240a28925604d09fc577c55bb7c32.
//
// Solidity: event TransactionDeposited(address indexed from, address indexed to, uint256 indexed version, bytes opaqueData)
func (_Portal *PortalFilterer) FilterTransactionDeposited(opts *bind.FilterOpts, from []common.Address, to []common.Address, version []*big.Int) (*PortalTransactionDepositedIterator, error) {
var fromRule []interface{}
for _, fromItem := range from {
fromRule = append(fromRule, fromItem)
}
var toRule []interface{}
for _, toItem := range to {
toRule = append(toRule, toItem)
}
var versionRule []interface{}
for _, versionItem := range version {
versionRule = append(versionRule, versionItem)
}
logs, sub, err := _Portal.contract.FilterLogs(opts, "TransactionDeposited", fromRule, toRule, versionRule)
if err != nil {
return nil, err
}
return &PortalTransactionDepositedIterator{contract: _Portal.contract, event: "TransactionDeposited", logs: logs, sub: sub}, nil
}
// WatchTransactionDeposited is a free log subscription operation binding the contract event 0xb3813568d9991fc951961fcb4c784893574240a28925604d09fc577c55bb7c32.
//
// Solidity: event TransactionDeposited(address indexed from, address indexed to, uint256 indexed version, bytes opaqueData)
func (_Portal *PortalFilterer) WatchTransactionDeposited(opts *bind.WatchOpts, sink chan<- *PortalTransactionDeposited, from []common.Address, to []common.Address, version []*big.Int) (event.Subscription, error) {
var fromRule []interface{}
for _, fromItem := range from {
fromRule = append(fromRule, fromItem)
}
var toRule []interface{}
for _, toItem := range to {
toRule = append(toRule, toItem)
}
var versionRule []interface{}
for _, versionItem := range version {
versionRule = append(versionRule, versionItem)
}
logs, sub, err := _Portal.contract.WatchLogs(opts, "TransactionDeposited", fromRule, toRule, versionRule)
if err != nil {
return nil, err
}
return event.NewSubscription(func(quit <-chan struct{}) error {
defer sub.Unsubscribe()
for {
select {
case log := <-logs:
// New log arrived, parse the event and forward to the user
event := new(PortalTransactionDeposited)
if err := _Portal.contract.UnpackLog(event, "TransactionDeposited", log); err != nil {
return err
}
event.Raw = log
select {
case sink <- event:
case err := <-sub.Err():
return err
case <-quit:
return nil
}
case err := <-sub.Err():
return err
case <-quit:
return nil
}
}
}), nil
}
// ParseTransactionDeposited is a log parse operation binding the contract event 0xb3813568d9991fc951961fcb4c784893574240a28925604d09fc577c55bb7c32.
//
// Solidity: event TransactionDeposited(address indexed from, address indexed to, uint256 indexed version, bytes opaqueData)
func (_Portal *PortalFilterer) ParseTransactionDeposited(log types.Log) (*PortalTransactionDeposited, error) {
event := new(PortalTransactionDeposited)
if err := _Portal.contract.UnpackLog(event, "TransactionDeposited", log); err != nil {
return nil, err
}
event.Raw = log
return event, nil
}
// PortalWithdrawalFinalizedIterator is returned from FilterWithdrawalFinalized and is used to iterate over the raw logs and unpacked data for WithdrawalFinalized events raised by the Portal contract.
type PortalWithdrawalFinalizedIterator struct {
Event *PortalWithdrawalFinalized // Event containing the contract specifics and raw log
contract *bind.BoundContract // Generic contract to use for unpacking event data
event string // Event name to use for unpacking event data
logs chan types.Log // Log channel receiving the found contract events
sub ethereum.Subscription // Subscription for errors, completion and termination
done bool // Whether the subscription completed delivering logs
fail error // Occurred error to stop iteration
}
// Next advances the iterator to the subsequent event, returning whether there
// are any more events found. In case of a retrieval or parsing error, false is
// returned and Error() can be queried for the exact failure.
func (it *PortalWithdrawalFinalizedIterator) Next() bool {
// If the iterator failed, stop iterating
if it.fail != nil {
return false
}
// If the iterator completed, deliver directly whatever's available
if it.done {
select {
case log := <-it.logs:
it.Event = new(PortalWithdrawalFinalized)
if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil {
it.fail = err
return false
}
it.Event.Raw = log
return true
default:
return false
}
}
// Iterator still in progress, wait for either a data or an error event
select {
case log := <-it.logs:
it.Event = new(PortalWithdrawalFinalized)
if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil {
it.fail = err
return false
}
it.Event.Raw = log
return true
case err := <-it.sub.Err():
it.done = true
it.fail = err
return it.Next()
}
}
// Error returns any retrieval or parsing error occurred during filtering.
func (it *PortalWithdrawalFinalizedIterator) Error() error {
return it.fail
}
// Close terminates the iteration process, releasing any pending underlying
// resources.
func (it *PortalWithdrawalFinalizedIterator) Close() error {
it.sub.Unsubscribe()
return nil
}
// PortalWithdrawalFinalized represents a WithdrawalFinalized event raised by the Portal contract.
type PortalWithdrawalFinalized struct {
WithdrawalHash [32]byte
Success bool
Raw types.Log // Blockchain specific contextual infos
}
// FilterWithdrawalFinalized is a free log retrieval operation binding the contract event 0xdb5c7652857aa163daadd670e116628fb42e869d8ac4251ef8971d9e5727df1b.
//
// Solidity: event WithdrawalFinalized(bytes32 indexed withdrawalHash, bool success)
func (_Portal *PortalFilterer) FilterWithdrawalFinalized(opts *bind.FilterOpts, withdrawalHash [][32]byte) (*PortalWithdrawalFinalizedIterator, error) {
var withdrawalHashRule []interface{}
for _, withdrawalHashItem := range withdrawalHash {
withdrawalHashRule = append(withdrawalHashRule, withdrawalHashItem)
}
logs, sub, err := _Portal.contract.FilterLogs(opts, "WithdrawalFinalized", withdrawalHashRule)
if err != nil {
return nil, err
}
return &PortalWithdrawalFinalizedIterator{contract: _Portal.contract, event: "WithdrawalFinalized", logs: logs, sub: sub}, nil
}
// WatchWithdrawalFinalized is a free log subscription operation binding the contract event 0xdb5c7652857aa163daadd670e116628fb42e869d8ac4251ef8971d9e5727df1b.
//
// Solidity: event WithdrawalFinalized(bytes32 indexed withdrawalHash, bool success)
func (_Portal *PortalFilterer) WatchWithdrawalFinalized(opts *bind.WatchOpts, sink chan<- *PortalWithdrawalFinalized, withdrawalHash [][32]byte) (event.Subscription, error) {
var withdrawalHashRule []interface{}
for _, withdrawalHashItem := range withdrawalHash {
withdrawalHashRule = append(withdrawalHashRule, withdrawalHashItem)
}
logs, sub, err := _Portal.contract.WatchLogs(opts, "WithdrawalFinalized", withdrawalHashRule)
if err != nil {
return nil, err
}
return event.NewSubscription(func(quit <-chan struct{}) error {
defer sub.Unsubscribe()
for {
select {
case log := <-logs:
// New log arrived, parse the event and forward to the user
event := new(PortalWithdrawalFinalized)
if err := _Portal.contract.UnpackLog(event, "WithdrawalFinalized", log); err != nil {
return err
}
event.Raw = log
select {
case sink <- event:
case err := <-sub.Err():
return err
case <-quit:
return nil
}
case err := <-sub.Err():
return err
case <-quit:
return nil
}
}
}), nil
}
// ParseWithdrawalFinalized is a log parse operation binding the contract event 0xdb5c7652857aa163daadd670e116628fb42e869d8ac4251ef8971d9e5727df1b.
//
// Solidity: event WithdrawalFinalized(bytes32 indexed withdrawalHash, bool success)
func (_Portal *PortalFilterer) ParseWithdrawalFinalized(log types.Log) (*PortalWithdrawalFinalized, error) {
event := new(PortalWithdrawalFinalized)
if err := _Portal.contract.UnpackLog(event, "WithdrawalFinalized", log); err != nil {
return nil, err
}
event.Raw = log
return event, nil
}
// PortalWithdrawalProvenIterator is returned from FilterWithdrawalProven and is used to iterate over the raw logs and unpacked data for WithdrawalProven events raised by the Portal contract.
type PortalWithdrawalProvenIterator struct {
Event *PortalWithdrawalProven // Event containing the contract specifics and raw log
contract *bind.BoundContract // Generic contract to use for unpacking event data
event string // Event name to use for unpacking event data
logs chan types.Log // Log channel receiving the found contract events
sub ethereum.Subscription // Subscription for errors, completion and termination
done bool // Whether the subscription completed delivering logs
fail error // Occurred error to stop iteration
}
// Next advances the iterator to the subsequent event, returning whether there
// are any more events found. In case of a retrieval or parsing error, false is
// returned and Error() can be queried for the exact failure.
func (it *PortalWithdrawalProvenIterator) Next() bool {
// If the iterator failed, stop iterating
if it.fail != nil {
return false
}
// If the iterator completed, deliver directly whatever's available
if it.done {
select {
case log := <-it.logs:
it.Event = new(PortalWithdrawalProven)
if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil {
it.fail = err
return false
}
it.Event.Raw = log
return true
default:
return false
}
}
// Iterator still in progress, wait for either a data or an error event
select {
case log := <-it.logs:
it.Event = new(PortalWithdrawalProven)
if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil {
it.fail = err
return false
}
it.Event.Raw = log
return true
case err := <-it.sub.Err():
it.done = true
it.fail = err
return it.Next()
}
}
// Error returns any retrieval or parsing error occurred during filtering.
func (it *PortalWithdrawalProvenIterator) Error() error {
return it.fail
}
// Close terminates the iteration process, releasing any pending underlying
// resources.
func (it *PortalWithdrawalProvenIterator) Close() error {
it.sub.Unsubscribe()
return nil
}
// PortalWithdrawalProven represents a WithdrawalProven event raised by the Portal contract.
type PortalWithdrawalProven struct {
WithdrawalHash [32]byte
From common.Address
To common.Address
Raw types.Log // Blockchain specific contextual infos
}
// FilterWithdrawalProven is a free log retrieval operation binding the contract event 0x67a6208cfcc0801d50f6cbe764733f4fddf66ac0b04442061a8a8c0cb6b63f62.
//
// Solidity: event WithdrawalProven(bytes32 indexed withdrawalHash, address indexed from, address indexed to)
func (_Portal *PortalFilterer) FilterWithdrawalProven(opts *bind.FilterOpts, withdrawalHash [][32]byte, from []common.Address, to []common.Address) (*PortalWithdrawalProvenIterator, error) {
var withdrawalHashRule []interface{}
for _, withdrawalHashItem := range withdrawalHash {
withdrawalHashRule = append(withdrawalHashRule, withdrawalHashItem)
}
var fromRule []interface{}
for _, fromItem := range from {
fromRule = append(fromRule, fromItem)
}
var toRule []interface{}
for _, toItem := range to {
toRule = append(toRule, toItem)
}
logs, sub, err := _Portal.contract.FilterLogs(opts, "WithdrawalProven", withdrawalHashRule, fromRule, toRule)
if err != nil {
return nil, err
}
return &PortalWithdrawalProvenIterator{contract: _Portal.contract, event: "WithdrawalProven", logs: logs, sub: sub}, nil
}
// WatchWithdrawalProven is a free log subscription operation binding the contract event 0x67a6208cfcc0801d50f6cbe764733f4fddf66ac0b04442061a8a8c0cb6b63f62.
//
// Solidity: event WithdrawalProven(bytes32 indexed withdrawalHash, address indexed from, address indexed to)
func (_Portal *PortalFilterer) WatchWithdrawalProven(opts *bind.WatchOpts, sink chan<- *PortalWithdrawalProven, withdrawalHash [][32]byte, from []common.Address, to []common.Address) (event.Subscription, error) {
var withdrawalHashRule []interface{}
for _, withdrawalHashItem := range withdrawalHash {
withdrawalHashRule = append(withdrawalHashRule, withdrawalHashItem)
}
var fromRule []interface{}
for _, fromItem := range from {
fromRule = append(fromRule, fromItem)
}
var toRule []interface{}
for _, toItem := range to {
toRule = append(toRule, toItem)
}
logs, sub, err := _Portal.contract.WatchLogs(opts, "WithdrawalProven", withdrawalHashRule, fromRule, toRule)
if err != nil {
return nil, err
}
return event.NewSubscription(func(quit <-chan struct{}) error {
defer sub.Unsubscribe()
for {
select {
case log := <-logs:
// New log arrived, parse the event and forward to the user
event := new(PortalWithdrawalProven)
if err := _Portal.contract.UnpackLog(event, "WithdrawalProven", log); err != nil {
return err
}
event.Raw = log
select {
case sink <- event:
case err := <-sub.Err():
return err
case <-quit:
return nil
}
case err := <-sub.Err():
return err
case <-quit:
return nil
}
}
}), nil
}
// ParseWithdrawalProven is a log parse operation binding the contract event 0x67a6208cfcc0801d50f6cbe764733f4fddf66ac0b04442061a8a8c0cb6b63f62.
//
// Solidity: event WithdrawalProven(bytes32 indexed withdrawalHash, address indexed from, address indexed to)
func (_Portal *PortalFilterer) ParseWithdrawalProven(log types.Log) (*PortalWithdrawalProven, error) {
event := new(PortalWithdrawalProven)
if err := _Portal.contract.UnpackLog(event, "WithdrawalProven", log); err != nil {
return nil, err
}
event.Raw = log
return event, nil
}
[{"type":"constructor","inputs":[],"stateMutability":"nonpayable"},{"type":"receive","stateMutability":"payable"},{"type":"function","name":"balance","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"batchExChainWithdrawal","inputs":[{"name":"_params","type":"tuple[]","internalType":"struct Types.BatchExChainWithdrawalParam[]","components":[{"name":"value","type":"uint256","internalType":"uint256"},{"name":"user","type":"address","internalType":"address"},{"name":"coin","type":"bytes","internalType":"bytes"},{"name":"txHash","type":"bytes32","internalType":"bytes32"},{"name":"_withdrawalProof","type":"bytes[]","internalType":"bytes[]"}]},{"name":"_l2OutputIndex","type":"uint256","internalType":"uint256"},{"name":"_outputRootProof","type":"tuple","internalType":"struct Types.OutputRootProof","components":[{"name":"version","type":"bytes32","internalType":"bytes32"},{"name":"stateRoot","type":"bytes32","internalType":"bytes32"},{"name":"messagePasserStorageRoot","type":"bytes32","internalType":"bytes32"},{"name":"latestBlockhash","type":"bytes32","internalType":"bytes32"}]}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"depositERC20Transaction","inputs":[{"name":"_to","type":"address","internalType":"address"},{"name":"_mint","type":"uint256","internalType":"uint256"},{"name":"_value","type":"uint256","internalType":"uint256"},{"name":"_gasLimit","type":"uint64","internalType":"uint64"},{"name":"_isCreation","type":"bool","internalType":"bool"},{"name":"_data","type":"bytes","internalType":"bytes"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"depositTransaction","inputs":[{"name":"_to","type":"address","internalType":"address"},{"name":"_value","type":"uint256","internalType":"uint256"},{"name":"_gasLimit","type":"uint64","internalType":"uint64"},{"name":"_isCreation","type":"bool","internalType":"bool"},{"name":"_data","type":"bytes","internalType":"bytes"}],"outputs":[],"stateMutability":"payable"},{"type":"function","name":"donateETH","inputs":[],"outputs":[],"stateMutability":"payable"},{"type":"function","name":"exChainWithdrawal","inputs":[{"name":"_param","type":"tuple","internalType":"struct Types.ExChainWithdrawalParam","components":[{"name":"value","type":"uint256","internalType":"uint256"},{"name":"user","type":"address","internalType":"address"},{"name":"coin","type":"bytes","internalType":"bytes"},{"name":"txHash","type":"bytes32","internalType":"bytes32"}]},{"name":"_l2OutputIndex","type":"uint256","internalType":"uint256"},{"name":"_outputRootProof","type":"tuple","internalType":"struct Types.OutputRootProof","components":[{"name":"version","type":"bytes32","internalType":"bytes32"},{"name":"stateRoot","type":"bytes32","internalType":"bytes32"},{"name":"messagePasserStorageRoot","type":"bytes32","internalType":"bytes32"},{"name":"latestBlockhash","type":"bytes32","internalType":"bytes32"}]},{"name":"_withdrawalProof","type":"bytes[]","internalType":"bytes[]"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"finalizeWithdrawalTransaction","inputs":[{"name":"_tx","type":"tuple","internalType":"struct Types.WithdrawalTransaction","components":[{"name":"nonce","type":"uint256","internalType":"uint256"},{"name":"sender","type":"address","internalType":"address"},{"name":"target","type":"address","internalType":"address"},{"name":"value","type":"uint256","internalType":"uint256"},{"name":"gasLimit","type":"uint256","internalType":"uint256"},{"name":"data","type":"bytes","internalType":"bytes"}]}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"finalizedWithdrawals","inputs":[{"name":"","type":"bytes32","internalType":"bytes32"}],"outputs":[{"name":"","type":"bool","internalType":"bool"}],"stateMutability":"view"},{"type":"function","name":"guardian","inputs":[],"outputs":[{"name":"","type":"address","internalType":"address"}],"stateMutability":"view"},{"type":"function","name":"initialize","inputs":[{"name":"_l2Oracle","type":"address","internalType":"contract L2OutputOracle"},{"name":"_systemConfig","type":"address","internalType":"contract SystemConfig"},{"name":"_superchainConfig","type":"address","internalType":"contract SuperchainConfig"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"isOutputFinalized","inputs":[{"name":"_l2OutputIndex","type":"uint256","internalType":"uint256"}],"outputs":[{"name":"","type":"bool","internalType":"bool"}],"stateMutability":"view"},{"type":"function","name":"l2Oracle","inputs":[],"outputs":[{"name":"","type":"address","internalType":"contract L2OutputOracle"}],"stateMutability":"view"},{"type":"function","name":"l2Sender","inputs":[],"outputs":[{"name":"","type":"address","internalType":"address"}],"stateMutability":"view"},{"type":"function","name":"minimumGasLimit","inputs":[{"name":"_byteCount","type":"uint64","internalType":"uint64"}],"outputs":[{"name":"","type":"uint64","internalType":"uint64"}],"stateMutability":"pure"},{"type":"function","name":"params","inputs":[],"outputs":[{"name":"prevBaseFee","type":"uint128","internalType":"uint128"},{"name":"prevBoughtGas","type":"uint64","internalType":"uint64"},{"name":"prevBlockNum","type":"uint64","internalType":"uint64"}],"stateMutability":"view"},{"type":"function","name":"paused","inputs":[],"outputs":[{"name":"paused_","type":"bool","internalType":"bool"}],"stateMutability":"view"},{"type":"function","name":"proveWithdrawalTransaction","inputs":[{"name":"_tx","type":"tuple","internalType":"struct Types.WithdrawalTransaction","components":[{"name":"nonce","type":"uint256","internalType":"uint256"},{"name":"sender","type":"address","internalType":"address"},{"name":"target","type":"address","internalType":"address"},{"name":"value","type":"uint256","internalType":"uint256"},{"name":"gasLimit","type":"uint256","internalType":"uint256"},{"name":"data","type":"bytes","internalType":"bytes"}]},{"name":"_l2OutputIndex","type":"uint256","internalType":"uint256"},{"name":"_outputRootProof","type":"tuple","internalType":"struct Types.OutputRootProof","components":[{"name":"version","type":"bytes32","internalType":"bytes32"},{"name":"stateRoot","type":"bytes32","internalType":"bytes32"},{"name":"messagePasserStorageRoot","type":"bytes32","internalType":"bytes32"},{"name":"latestBlockhash","type":"bytes32","internalType":"bytes32"}]},{"name":"_withdrawalProof","type":"bytes[]","internalType":"bytes[]"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"provenWithdrawals","inputs":[{"name":"","type":"bytes32","internalType":"bytes32"}],"outputs":[{"name":"outputRoot","type":"bytes32","internalType":"bytes32"},{"name":"timestamp","type":"uint128","internalType":"uint128"},{"name":"l2OutputIndex","type":"uint128","internalType":"uint128"}],"stateMutability":"view"},{"type":"function","name":"setGasPayingToken","inputs":[{"name":"_token","type":"address","internalType":"address"},{"name":"_decimals","type":"uint8","internalType":"uint8"},{"name":"_name","type":"bytes32","internalType":"bytes32"},{"name":"_symbol","type":"bytes32","internalType":"bytes32"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"superchainConfig","inputs":[],"outputs":[{"name":"","type":"address","internalType":"contract SuperchainConfig"}],"stateMutability":"view"},{"type":"function","name":"systemConfig","inputs":[],"outputs":[{"name":"","type":"address","internalType":"contract SystemConfig"}],"stateMutability":"view"},{"type":"function","name":"version","inputs":[],"outputs":[{"name":"","type":"string","internalType":"string"}],"stateMutability":"pure"},{"type":"event","name":"Initialized","inputs":[{"name":"version","type":"uint8","indexed":false,"internalType":"uint8"}],"anonymous":false},{"type":"event","name":"TransactionDeposited","inputs":[{"name":"from","type":"address","indexed":true,"internalType":"address"},{"name":"to","type":"address","indexed":true,"internalType":"address"},{"name":"version","type":"uint256","indexed":true,"internalType":"uint256"},{"name":"opaqueData","type":"bytes","indexed":false,"internalType":"bytes"}],"anonymous":false},{"type":"event","name":"WithdrawalFinalized","inputs":[{"name":"withdrawalHash","type":"bytes32","indexed":true,"internalType":"bytes32"},{"name":"success","type":"bool","indexed":false,"internalType":"bool"}],"anonymous":false},{"type":"event","name":"WithdrawalProven","inputs":[{"name":"withdrawalHash","type":"bytes32","indexed":true,"internalType":"bytes32"},{"name":"from","type":"address","indexed":true,"internalType":"address"},{"name":"to","type":"address","indexed":true,"internalType":"address"}],"anonymous":false},{"type":"error","name":"BadTarget","inputs":[]},{"type":"error","name":"CallPaused","inputs":[]},{"type":"error","name":"ContentLengthMismatch","inputs":[]},{"type":"error","name":"EmptyItem","inputs":[]},{"type":"error","name":"InvalidDataRemainder","inputs":[]},{"type":"error","name":"InvalidHeader","inputs":[]},{"type":"error","name":"LargeCalldata","inputs":[]},{"type":"error","name":"NoValue","inputs":[]},{"type":"error","name":"OnlyCustomGasToken","inputs":[]},{"type":"error","name":"OutOfGas","inputs":[]},{"type":"error","name":"SmallGasLimit","inputs":[]},{"type":"error","name":"TransferFailed","inputs":[]},{"type":"error","name":"Unauthorized","inputs":[]},{"type":"error","name":"UnexpectedList","inputs":[]},{"type":"error","name":"UnexpectedString","inputs":[]}]
......@@ -33,12 +33,24 @@ var (
EnvVars: prefixEnvVars("ROLLUP_RPC"),
}
DataDirFlag = &cli.StringFlag{
Name: "data-dir",
Usage: "Data directory for the proposer",
Value: "data",
EnvVars: prefixEnvVars("DATA_DIR"),
}
// Optional flags
L2OOAddressFlag = &cli.StringFlag{
Name: "l2oo-address",
Usage: "Address of the L2OutputOracle contract",
EnvVars: prefixEnvVars("L2OO_ADDRESS"),
}
PortalAddressFlag = &cli.StringFlag{
Name: "portal-address",
Usage: "Address of the Portal contract",
EnvVars: prefixEnvVars("PORTAL_ADDRESS"),
}
PollIntervalFlag = &cli.DurationFlag{
Name: "poll-interval",
Usage: "How frequently to poll L2 for new blocks (legacy L2OO)",
......@@ -91,6 +103,8 @@ var requiredFlags = []cli.Flag{
var optionalFlags = []cli.Flag{
L2OOAddressFlag,
PortalAddressFlag,
DataDirFlag,
PollIntervalFlag,
AllowNonFinalizedFlag,
L2OutputHDPathFlag,
......
......@@ -29,6 +29,12 @@ type CLIConfig struct {
// L2OOAddress is the L2OutputOracle contract address.
L2OOAddress string
// PortalAddress is the Portal contract address.
PortalAddress string
// DataDir is the data directory for the proposer.
DataDir string
// PollInterval is the delay between querying L2 for more transaction
// and creating a new batch.
PollInterval time.Duration
......@@ -97,11 +103,13 @@ func (c *CLIConfig) Check() error {
func NewConfig(ctx *cli.Context) *CLIConfig {
return &CLIConfig{
// Required Flags
L1EthRpc: ctx.String(flags.L1EthRpcFlag.Name),
RollupRpc: ctx.String(flags.RollupRpcFlag.Name),
L2OOAddress: ctx.String(flags.L2OOAddressFlag.Name),
PollInterval: ctx.Duration(flags.PollIntervalFlag.Name),
TxMgrConfig: txmgr.ReadCLIConfig(ctx),
L1EthRpc: ctx.String(flags.L1EthRpcFlag.Name),
RollupRpc: ctx.String(flags.RollupRpcFlag.Name),
L2OOAddress: ctx.String(flags.L2OOAddressFlag.Name),
PortalAddress: ctx.String(flags.PortalAddressFlag.Name),
DataDir: ctx.String(flags.DataDirFlag.Name),
PollInterval: ctx.Duration(flags.PollIntervalFlag.Name),
TxMgrConfig: txmgr.ReadCLIConfig(ctx),
// Optional Flags
AllowNonFinalized: ctx.Bool(flags.AllowNonFinalizedFlag.Name),
RPCConfig: oprpc.ReadCLIConfig(ctx),
......
......@@ -42,6 +42,9 @@ type L1Client interface {
type L2OOContract interface {
Version(*bind.CallOpts) (string, error)
NextBlockNumber(*bind.CallOpts) (*big.Int, error)
GetL2OutputIndexAfter(opts *bind.CallOpts, _l2BlockNumber *big.Int) (*big.Int, error)
GetL2Output(opts *bind.CallOpts, _l2OutputIndex *big.Int) (bindings.TypesOutputProposal, error)
LatestBlockNumber(opts *bind.CallOpts) (*big.Int, error)
}
type DGFContract interface {
......
package proposer
import (
"context"
"encoding/json"
"errors"
"fmt"
"github.com/ethereum/go-ethereum/common"
"github.com/exchain/go-exchain/metadb"
"math/big"
"sync"
"time"
"github.com/ethereum/go-ethereum/accounts/abi"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/log"
"github.com/exchain/go-exchain/op-proposer/bindings"
"github.com/exchain/go-exchain/op-service/dial"
"github.com/exchain/go-exchain/op-service/txmgr"
)
const (
progressKey = "operatorprogress"
progressTaskKey = "optask"
)
type WithdrawalContract interface {
Version(*bind.CallOpts) (string, error)
}
// Operator is responsible for proposing withdrawal tx to the L1 chain.
type Operator struct {
DriverSetup
wg sync.WaitGroup
done chan struct{}
ctx context.Context
cancel context.CancelFunc
mutex sync.Mutex
running bool
portalContract WithdrawalContract
l2ooContract L2OOContract
portalABI *abi.ABI
}
// NewOperator creates a new L2 Operator
func NewOperator(setup DriverSetup, db metadb.Database) (_ *Operator, err error) {
ctx, cancel := context.WithCancel(context.Background())
defer func() {
if err != nil || recover() != nil {
cancel()
}
}()
if setup.Cfg.PortalAddr != nil {
return newOperator(ctx, cancel, setup)
} else {
return nil, errors.New("the `PortalAddr` were not provided")
}
}
type OperatorProgress struct {
BlockNumber uint64 `json:"block_number"`
Index uint64 `json:"index"`
Total uint64 `json:"total"`
}
type OperatorTask struct {
TxHash string `json:"tx_hash"`
}
type OperatorTaskList []OperatorTask
func (l *Operator) GetOperatorTaskList() OperatorTaskList {
value, err := l.Cfg.Database.Get([]byte(progressTaskKey))
if err != nil {
return OperatorTaskList{}
}
var taskList OperatorTaskList
if err = json.Unmarshal(value, &taskList); err != nil {
l.Log.Error("failed to unmarshal operator task list", "err", err)
}
return taskList
}
func (l *Operator) SetOperatorTaskList(taskList OperatorTaskList) {
value, err := json.Marshal(taskList)
if err != nil {
l.Log.Error("failed to marshal operator task list", "err", err)
return
}
if err = l.Cfg.Database.Put([]byte(progressTaskKey), value); err != nil {
l.Log.Error("failed to set operator task list", "err", err)
return
}
}
func (l *Operator) GetProgress() OperatorProgress {
value, err := l.Cfg.Database.Get([]byte(progressKey))
if err != nil {
return OperatorProgress{}
}
var progress OperatorProgress
if err = json.Unmarshal(value, &progress); err != nil {
l.Log.Error("failed to unmarshal operator progress", "err", err)
}
return progress
}
func (l *Operator) SetProgress(blockNum uint64, index uint64) {
progress := OperatorProgress{
BlockNumber: blockNum,
Index: index,
}
value, err := json.Marshal(progress)
if err != nil {
l.Log.Error("failed to marshal operator progress", "err", err)
return
}
if err = l.Cfg.Database.Put([]byte(progressKey), value); err != nil {
l.Log.Error("failed to set operator progress", "err", err)
}
}
func newOperator(ctx context.Context, cancel context.CancelFunc, setup DriverSetup) (*Operator, error) {
l2ooContract, err := bindings.NewL2OutputOracleCaller(*setup.Cfg.L2OutputOracleAddr, setup.L1Client)
if err != nil {
cancel()
return nil, fmt.Errorf("failed to create L2OO at address %s: %w", setup.Cfg.L2OutputOracleAddr, err)
}
portalContract, err := bindings.NewPortalCaller(*setup.Cfg.PortalAddr, setup.L1Client)
if err != nil {
cancel()
return nil, fmt.Errorf("failed to create L2OO at address %s: %w", setup.Cfg.PortalAddr, err)
}
cCtx, cCancel := context.WithTimeout(ctx, setup.Cfg.NetworkTimeout)
defer cCancel()
version, err := portalContract.Version(&bind.CallOpts{Context: cCtx})
if err != nil {
cancel()
return nil, err
}
log.Info("Connected to Portal", "address", setup.Cfg.PortalAddr, "version", version)
parsed, err := bindings.PortalMetaData.GetAbi()
if err != nil {
cancel()
return nil, err
}
return &Operator{
DriverSetup: setup,
done: make(chan struct{}),
ctx: ctx,
cancel: cancel,
portalContract: portalContract,
l2ooContract: l2ooContract,
portalABI: parsed,
}, nil
}
func (l *Operator) StartOperator() error {
l.Log.Info("Starting Proposer operator")
l.mutex.Lock()
defer l.mutex.Unlock()
if l.running {
return errors.New("proposer operator is already running")
}
l.running = true
if l.Cfg.WaitNodeSync {
err := l.waitNodeSync()
if err != nil {
return fmt.Errorf("error waiting for node sync: %w", err)
}
}
l.wg.Add(1)
go l.loop()
l.Log.Info("Proposer operator started")
return nil
}
func (l *Operator) StopOperatorIfRunning() error {
err := l.StopOperator()
if errors.Is(err, ErrProposerNotRunning) {
return nil
}
return err
}
func (l *Operator) getL2ooIndex(callOpts *bind.CallOpts, l2BlockNumber uint64) (*big.Int, error) {
index, err := l.l2ooContract.GetL2OutputIndexAfter(callOpts, big.NewInt(int64(l2BlockNumber)))
if err != nil {
l.Log.Error("failed to get l2 output index after", "err", err)
return nil, err
}
return index, nil
}
func (l *Operator) StopOperator() error {
l.Log.Info("Stopping Proposer operator")
l.mutex.Lock()
defer l.mutex.Unlock()
if !l.running {
return ErrProposerNotRunning
}
l.running = false
l.cancel()
close(l.done)
l.wg.Wait()
l.Log.Info("Proposer operator stopped")
return nil
}
func (l *Operator) DoOperator(ctx context.Context) {
progress := l.GetProgress()
cCtx, cancel := context.WithTimeout(ctx, l.Cfg.NetworkTimeout)
defer cancel()
callOpts := &bind.CallOpts{
From: l.Txmgr.From(),
Context: cCtx,
}
// 1. check current latest submitted block number on l2oo.
l2Latest, err := l.l2ooContract.LatestBlockNumber(callOpts)
if err != nil {
l.Log.Error("failed to get latest block number from l2oo", "err", err)
return
}
l.Log.Debug("latest block number from l2oo", "l2Latest", l2Latest)
currentFinished := false
if progress.Total == 0 || progress.Index == (progress.Total-1) {
currentFinished = true
}
// 2. check current process is finished.
rollupClient, err := l.RollupProvider.RollupClient(ctx)
if err != nil {
l.Log.Error("failed to get rollup client in withdrawal tx operator", "err", err)
return
}
if !currentFinished { // if current progress is not finished, we need finish it first.
// get saved withdrawal tx hashes from db, and iterator to do withdrawal.
ooIndex, err := l.getL2ooIndex(callOpts, progress.BlockNumber)
if err != nil {
l.Log.Error("failed to get l2oo index and output", "err", err)
return
}
task := l.GetOperatorTaskList()
if uint64(len(task)) != progress.Total {
l.Log.Warn("task list length is not equal to progress total", "task count", len(task), "progress", progress)
progress.Total = uint64(len(task))
}
index := progress.Index
for index < progress.Total {
tx := task[progress.Index]
proof, err := rollupClient.WithdrawalProof(ctx, common.HexToHash(tx.TxHash))
if err != nil {
l.Log.Error("failed to get withdrawal proof", "err", err)
break
} else {
// call contract to do withdrawal.
params := bindings.TypesBatchExChainWithdrawalParam{
WithdrawalProof: make([][]byte, len(proof.Proof)),
Value: proof.Value,
User: proof.User,
Coin: proof.Coin,
TxHash: common.HexToHash(tx.TxHash),
}
for i, p := range proof.Proof {
params.WithdrawalProof[i] = p[:]
}
ooProof := bindings.TypesOutputRootProof{
StateRoot: proof.Output.StateRoot,
MessagePasserStorageRoot: proof.Output.MessagePasserStorageRoot,
LatestBlockhash: proof.Output.BlockHash,
}
err = l.doWithdrawal(ctx, []bindings.TypesBatchExChainWithdrawalParam{params}, ooIndex, ooProof)
if err != nil {
l.Log.Error("failed to do withdrawal", "err", err)
return
} else {
index++
// update process.
l.SetProgress(index, progress.Total)
}
}
}
}
// 3. check local progress is less than the latest submitted block number.
if progress.BlockNumber >= l2Latest.Uint64() {
l.Log.Debug("progress is reach latest")
return
}
// 4. to process next block.
for blkNum := progress.BlockNumber + 1; blkNum <= l2Latest.Uint64(); blkNum++ {
withDrawalTxs := make([]common.Hash, 0)
if txs, err := rollupClient.WithdrawalTxs(ctx, blkNum); err != nil {
l.Log.Error("failed to get withdrawal txs", "blknum", blkNum, "err", err)
return
} else {
withDrawalTxs = append(withDrawalTxs, txs...)
}
newProgress := OperatorProgress{
BlockNumber: blkNum,
Index: 0,
Total: uint64(len(withDrawalTxs)),
}
tasks := make([]OperatorTask, 0)
for _, tx := range withDrawalTxs {
task := OperatorTask{
TxHash: tx.Hex(),
}
tasks = append(tasks, task)
}
l.SetOperatorTaskList(tasks)
l.SetProgress(newProgress.BlockNumber, newProgress.Index)
ooIndex, err := l.getL2ooIndex(callOpts, progress.BlockNumber)
if err != nil {
l.Log.Error("failed to get l2oo index and output", "err", err)
return
}
// 5. to process each withdrawal tx.
index := newProgress.Index
for index < newProgress.Total {
tx := tasks[index]
proof, err := rollupClient.WithdrawalProof(ctx, common.HexToHash(tx.TxHash))
if err != nil {
l.Log.Error("failed to get withdrawal proof", "err", err)
break
} else {
// call contract to do withdrawal.
params := bindings.TypesBatchExChainWithdrawalParam{
WithdrawalProof: make([][]byte, len(proof.Proof)),
Value: proof.Value,
User: proof.User,
Coin: proof.Coin,
TxHash: common.HexToHash(tx.TxHash),
}
for i, p := range proof.Proof {
params.WithdrawalProof[i] = p[:]
}
ooProof := bindings.TypesOutputRootProof{
StateRoot: proof.Output.StateRoot,
MessagePasserStorageRoot: proof.Output.MessagePasserStorageRoot,
LatestBlockhash: proof.Output.BlockHash,
}
err = l.doWithdrawal(ctx, []bindings.TypesBatchExChainWithdrawalParam{params}, ooIndex, ooProof)
if err != nil {
l.Log.Error("failed to do withdrawal", "err", err)
return
} else {
index++
// update process.
l.SetProgress(index, newProgress.Total)
}
}
}
}
}
func (l *Operator) BatchExChainWithdrawalTxData(params []bindings.TypesBatchExChainWithdrawalParam, l2OutputIndex *big.Int, outputRootProof bindings.TypesOutputRootProof) ([]byte, error) {
return l.portalABI.Pack("batchExChainWithdrawal", params, l2OutputIndex, outputRootProof)
}
// sendTransaction creates & sends transactions through the underlying transaction manager.
func (l *Operator) sendTransaction(ctx context.Context, params []bindings.TypesBatchExChainWithdrawalParam, l2OutputIndex *big.Int, outputRootProof bindings.TypesOutputRootProof) error {
l.Log.Info("DoWithdrawal", "l2OutputIndex", l2OutputIndex)
var receipt *types.Receipt
{
data, err := l.BatchExChainWithdrawalTxData(params, l2OutputIndex, outputRootProof)
if err != nil {
return err
}
receipt, err = l.Txmgr.Send(ctx, txmgr.TxCandidate{
TxData: data,
To: l.Cfg.PortalAddr,
GasLimit: 0,
})
if err != nil {
return err
}
}
if receipt.Status == types.ReceiptStatusFailed {
l.Log.Error("Proposer withdrawal tx successfully published but reverted", "tx_hash", receipt.TxHash)
} else {
l.Log.Info("Proposer withdrawal tx successfully published",
"tx_hash", receipt.TxHash)
}
return nil
}
// loop is responsible for creating & submitting the next outputs
// The loop regularly polls the L2 chain to infer whether to make the next proposal.
func (l *Operator) loop() {
defer l.wg.Done()
defer l.Log.Info("loop returning")
ctx := l.ctx
ticker := time.NewTicker(l.Cfg.PollInterval)
defer ticker.Stop()
for {
select {
case <-ticker.C:
// prioritize quit signal
select {
case <-l.done:
return
default:
}
l.DoOperator(ctx)
case <-l.done:
return
}
}
}
func (l *Operator) waitNodeSync() error {
cCtx, cancel := context.WithTimeout(l.ctx, l.Cfg.NetworkTimeout)
defer cancel()
l1head, err := l.Txmgr.BlockNumber(cCtx)
if err != nil {
return fmt.Errorf("failed to retrieve current L1 block number: %w", err)
}
rollupClient, err := l.RollupProvider.RollupClient(l.ctx)
if err != nil {
return fmt.Errorf("failed to get rollup client: %w", err)
}
return dial.WaitRollupSync(l.ctx, l.Log, rollupClient, l1head, time.Second*12)
}
func (l *Operator) doWithdrawal(ctx context.Context, params []bindings.TypesBatchExChainWithdrawalParam, l2OutputIndex *big.Int, outputRootProof bindings.TypesOutputRootProof) error {
cCtx, cancel := context.WithTimeout(ctx, 10*time.Minute)
defer cancel()
if err := l.sendTransaction(cCtx, params, l2OutputIndex, outputRootProof); err != nil {
l.Log.Error("Failed to send proposal withdrawal transaction",
"err", err)
return err
}
return nil
}
......@@ -4,6 +4,8 @@ import (
"context"
"errors"
"fmt"
"github.com/exchain/go-exchain/metadb"
"github.com/exchain/go-exchain/metadb/storagedb"
"io"
"strings"
"sync/atomic"
......@@ -37,6 +39,8 @@ type ProposerConfig struct {
ProposalInterval time.Duration
L2OutputOracleAddr *common.Address
PortalAddr *common.Address
Database metadb.Database
DisputeGameFactoryAddr *common.Address
DisputeGameType uint32
......@@ -95,6 +99,8 @@ func (ps *ProposerService) initFromCLIConfig(ctx context.Context, version string
ps.WaitNodeSync = cfg.WaitNodeSync
ps.initL2ooAddress(cfg)
ps.initPortalAddress(cfg)
ps.initData(cfg)
ps.initDGF(cfg)
if err := ps.initRPCClients(ctx, cfg); err != nil {
......@@ -205,6 +211,20 @@ func (ps *ProposerService) initL2ooAddress(cfg *CLIConfig) {
ps.L2OutputOracleAddr = &l2ooAddress
}
func (ps *ProposerService) initPortalAddress(cfg *CLIConfig) {
portalAddress, err := opservice.ParseAddress(cfg.PortalAddress)
if err != nil {
// Return no error & set no L2OO related configuration fields.
return
}
ps.PortalAddr = &portalAddress
}
func (ps *ProposerService) initData(cfg *CLIConfig) {
db := storagedb.NewStorageDB(cfg.DataDir, "proposer")
ps.Database = db
}
func (ps *ProposerService) initDGF(cfg *CLIConfig) {
dgfAddress, err := opservice.ParseAddress(cfg.DGFAddress)
if err != nil {
......
......@@ -2,7 +2,6 @@ package dial
import (
"context"
"github.com/exchain/go-exchain/exchain"
"github.com/exchain/go-exchain/exchain/wrapper"
"math/big"
)
......@@ -11,6 +10,5 @@ import (
// It does not describe all of the functions an ethclient.Client has, only the ones used by callers of the L2 Providers
type ExchainClientInterface interface {
BlockByNumber(ctx context.Context, number *big.Int) (*wrapper.BlkWrapper, error)
GetWithdrawalProof(ctx context.Context, param exchain.ExChainWithdrawalParam) ([][]byte, error)
Close()
}
......@@ -3,9 +3,9 @@ package dial
import (
"context"
"github.com/ethereum/go-ethereum/common"
"github.com/exchain/go-exchain/op-node/rollup"
"github.com/exchain/go-exchain/op-service/eth"
"github.com/ethereum/go-ethereum/common"
)
// RollupClientInterface is an interface for providing a RollupClient
......@@ -16,6 +16,8 @@ type RollupClientInterface interface {
RollupConfig(ctx context.Context) (*rollup.Config, error)
StartSequencer(ctx context.Context, unsafeHead common.Hash) error
SequencerActive(ctx context.Context) (bool, error)
WithdrawalProof(ctx context.Context, txHash common.Hash) (*eth.WithdrawalProof, error)
WithdrawalTxs(ctx context.Context, blockNum uint64) ([]common.Hash, error)
Close()
}
......
package eth
import (
"github.com/ethereum/go-ethereum/common"
"math/big"
)
type WithdrawalProof struct {
Output OutputV0
Proof []Bytes32
Value *big.Int
User common.Address
Coin []byte
}
......@@ -26,6 +26,12 @@ func (r *RollupClient) WithdrawalProof(ctx context.Context, txHash common.Hash)
return output, err
}
func (r *RollupClient) WithdrawalTxs(ctx context.Context, blockNum uint64) ([]common.Hash, error) {
var output []common.Hash
err := r.rpc.CallContext(ctx, &output, "optimism_withdrawalTxs", hexutil.Uint64(blockNum))
return output, err
}
func (r *RollupClient) OutputAtBlock(ctx context.Context, blockNum uint64) (*eth.OutputResponse, error) {
var output *eth.OutputResponse
err := r.rpc.CallContext(ctx, &output, "optimism_outputAtBlock", hexutil.Uint64(blockNum))
......
......@@ -240,53 +240,229 @@ contract OptimismPortal is Initializable, ResourceMetering, ISemver {
external
whenNotPaused
{
// Prevent users from creating a deposit transaction where this address is the message
// sender on L2. Because this is checked here, we do not need to check again in
// `finalizeWithdrawalTransaction`.
if (_tx.target == address(this)) revert BadTarget();
revert("function has been disabled");
// // Prevent users from creating a deposit transaction where this address is the message
// // sender on L2. Because this is checked here, we do not need to check again in
// // `finalizeWithdrawalTransaction`.
// if (_tx.target == address(this)) revert BadTarget();
//
// // Get the output root and load onto the stack to prevent multiple mloads. This will
// // revert if there is no output root for the given block number.
// bytes32 outputRoot = l2Oracle.getL2Output(_l2OutputIndex).outputRoot;
//
// // Verify that the output root can be generated with the elements in the proof.
// require(
// outputRoot == Hashing.hashOutputRootProof(_outputRootProof), "OptimismPortal: invalid output root proof"
// );
//
// // Load the ProvenWithdrawal into memory, using the withdrawal hash as a unique identifier.
// bytes32 withdrawalHash = Hashing.hashWithdrawal(_tx);
// ProvenWithdrawal memory provenWithdrawal = provenWithdrawals[withdrawalHash];
//
// // We generally want to prevent users from proving the same withdrawal multiple times
// // because each successive proof will update the timestamp. A malicious user can take
// // advantage of this to prevent other users from finalizing their withdrawal. However,
// // since withdrawals are proven before an output root is finalized, we need to allow users
// // to re-prove their withdrawal only in the case that the output root for their specified
// // output index has been updated.
// require(
// provenWithdrawal.timestamp == 0
// || l2Oracle.getL2Output(provenWithdrawal.l2OutputIndex).outputRoot != provenWithdrawal.outputRoot,
// "OptimismPortal: withdrawal hash has already been proven"
// );
//
// // Compute the storage slot of the withdrawal hash in the L2ToL1MessagePasser contract.
// // Refer to the Solidity documentation for more information on how storage layouts are
// // computed for mappings.
// bytes32 storageKey = keccak256(
// abi.encode(
// withdrawalHash,
// uint256(0) // The withdrawals mapping is at the first slot in the layout.
// )
// );
//
// // Verify that the hash of this withdrawal was stored in the L2toL1MessagePasser contract
// // on L2. If this is true, under the assumption that the SecureMerkleTrie does not have
// // bugs, then we know that this withdrawal was actually triggered on L2 and can therefore
// // be relayed on L1.
// require(
// SecureMerkleTrie.verifyInclusionProof({
// _key: abi.encode(storageKey),
// _value: hex"01",
// _proof: _withdrawalProof,
// _root: _outputRootProof.messagePasserStorageRoot
// }),
// "OptimismPortal: invalid withdrawal inclusion proof"
// );
//
// // Designate the withdrawalHash as proven by storing the `outputRoot`, `timestamp`, and
// // `l2BlockNumber` in the `provenWithdrawals` mapping. A `withdrawalHash` can only be
// // proven once unless it is submitted again with a different outputRoot.
// provenWithdrawals[withdrawalHash] = ProvenWithdrawal({
// outputRoot: outputRoot,
// timestamp: uint128(block.timestamp),
// l2OutputIndex: uint128(_l2OutputIndex)
// });
//
// // Emit a `WithdrawalProven` event.
// emit WithdrawalProven(withdrawalHash, _tx.sender, _tx.target);
}
// Get the output root and load onto the stack to prevent multiple mloads. This will
// revert if there is no output root for the given block number.
bytes32 outputRoot = l2Oracle.getL2Output(_l2OutputIndex).outputRoot;
/// @notice Finalizes a withdrawal transaction.
/// @param _tx Withdrawal transaction to finalize.
function finalizeWithdrawalTransaction(Types.WithdrawalTransaction memory _tx) external whenNotPaused {
revert("function has been disabled");
// // Make sure that the l2Sender has not yet been set. The l2Sender is set to a value other
// // than the default value when a withdrawal transaction is being finalized. This check is
// // a defacto reentrancy guard.
// if (l2Sender != Constants.DEFAULT_L2_SENDER) revert NonReentrant();
//
// // Grab the proven withdrawal from the `provenWithdrawals` map.
// bytes32 withdrawalHash = Hashing.hashWithdrawal(_tx);
// ProvenWithdrawal memory provenWithdrawal = provenWithdrawals[withdrawalHash];
//
// // A withdrawal can only be finalized if it has been proven. We know that a withdrawal has
// // been proven at least once when its timestamp is non-zero. Unproven withdrawals will have
// // a timestamp of zero.
// require(provenWithdrawal.timestamp != 0, "OptimismPortal: withdrawal has not been proven yet");
//
// // As a sanity check, we make sure that the proven withdrawal's timestamp is greater than
// // starting timestamp inside the L2OutputOracle. Not strictly necessary but extra layer of
// // safety against weird bugs in the proving step.
// require(
// provenWithdrawal.timestamp >= l2Oracle.startingTimestamp(),
// "OptimismPortal: withdrawal timestamp less than L2 Oracle starting timestamp"
// );
//
// // A proven withdrawal must wait at least the finalization period before it can be
// // finalized. This waiting period can elapse in parallel with the waiting period for the
// // output the withdrawal was proven against. In effect, this means that the minimum
// // withdrawal time is proposal submission time + finalization period.
// require(
// _isFinalizationPeriodElapsed(provenWithdrawal.timestamp),
// "OptimismPortal: proven withdrawal finalization period has not elapsed"
// );
//
// // Grab the OutputProposal from the L2OutputOracle, will revert if the output that
// // corresponds to the given index has not been proposed yet.
// Types.OutputProposal memory proposal = l2Oracle.getL2Output(provenWithdrawal.l2OutputIndex);
//
// // Check that the output root that was used to prove the withdrawal is the same as the
// // current output root for the given output index. An output root may change if it is
// // deleted by the challenger address and then re-proposed.
// require(
// proposal.outputRoot == provenWithdrawal.outputRoot,
// "OptimismPortal: output root proven is not the same as current output root"
// );
//
// // Check that the output proposal has also been finalized.
// require(
// _isFinalizationPeriodElapsed(proposal.timestamp),
// "OptimismPortal: output proposal finalization period has not elapsed"
// );
//
// // Check that this withdrawal has not already been finalized, this is replay protection.
// require(finalizedWithdrawals[withdrawalHash] == false, "OptimismPortal: withdrawal has already been finalized");
//
// // Mark the withdrawal as finalized so it can't be replayed.
// finalizedWithdrawals[withdrawalHash] = true;
//
// // Set the l2Sender so contracts know who triggered this withdrawal on L2.
// // This acts as a reentrancy guard.
// l2Sender = _tx.sender;
//
// bool success;
// (address token,) = gasPayingToken();
// if (token == Constants.ETHER) {
// // Trigger the call to the target contract. We use a custom low level method
// // SafeCall.callWithMinGas to ensure two key properties
// // 1. Target contracts cannot force this call to run out of gas by returning a very large
// // amount of data (and this is OK because we don't care about the returndata here).
// // 2. The amount of gas provided to the execution context of the target is at least the
// // gas limit specified by the user. If there is not enough gas in the current context
// // to accomplish this, `callWithMinGas` will revert.
// success = SafeCall.callWithMinGas(_tx.target, _tx.gasLimit, _tx.value, _tx.data);
// } else {
// // Cannot call the token contract directly from the portal. This would allow an attacker
// // to call approve from a withdrawal and drain the balance of the portal.
// if (_tx.target == token) revert BadTarget();
//
// // Only transfer value when a non zero value is specified. This saves gas in the case of
// // using the standard bridge or arbitrary message passing.
// if (_tx.value != 0) {
// // Update the contracts internal accounting of the amount of native asset in L2.
// _balance -= _tx.value;
//
// // Read the balance of the target contract before the transfer so the consistency
// // of the transfer can be checked afterwards.
// uint256 startBalance = IERC20(token).balanceOf(address(this));
//
// // Transfer the ERC20 balance to the target, accounting for non standard ERC20
// // implementations that may not return a boolean. This reverts if the low level
// // call is not successful.
// IERC20(token).safeTransfer({ to: _tx.target, value: _tx.value });
//
// // The balance must be transferred exactly.
// if (IERC20(token).balanceOf(address(this)) != startBalance - _tx.value) {
// revert TransferFailed();
// }
// }
//
// // Make a call to the target contract only if there is calldata.
// if (_tx.data.length != 0) {
// success = SafeCall.callWithMinGas(_tx.target, _tx.gasLimit, 0, _tx.data);
// } else {
// success = true;
// }
// }
//
// // Reset the l2Sender back to the default value.
// l2Sender = Constants.DEFAULT_L2_SENDER;
//
// // All withdrawals are immediately finalized. Replayability can
// // be achieved through contracts built on top of this contract
// emit WithdrawalFinalized(withdrawalHash, success);
//
// // Reverting here is useful for determining the exact gas cost to successfully execute the
// // sub call to the target contract if the minimum gas limit specified by the user would not
// // be sufficient to execute the sub call.
// if (success == false && tx.origin == Constants.ESTIMATION_ADDRESS) {
// revert GasEstimation();
// }
}
// Verify that the output root can be generated with the elements in the proof.
require(
outputRoot == Hashing.hashOutputRootProof(_outputRootProof), "OptimismPortal: invalid output root proof"
);
// Load the ProvenWithdrawal into memory, using the withdrawal hash as a unique identifier.
bytes32 withdrawalHash = Hashing.hashWithdrawal(_tx);
/// @notice withdrawal for a user.
/// @param _param Withdrawal param to execute.
/// @param _l2OutputIndex L2 output index to prove against.
/// @param _outputRootProof Inclusion proof of the withdrawal's storage root.
/// @param _withdrawalProof Inclusion proof of the withdrawal.
function exChainWithdrawal(
Types.ExChainWithdrawalParam memory _param,
uint256 _l2OutputIndex,
Types.OutputRootProof calldata _outputRootProof,
bytes[] calldata _withdrawalProof
)
external
whenNotPaused
{
if (_param.user == address(this)) revert BadTarget();
bytes32 outputRoot = l2Oracle.getL2Output(_l2OutputIndex).outputRoot;
bytes32 withdrawalHash = Hashing.hashExChainWithdrawal(_param);
ProvenWithdrawal memory provenWithdrawal = provenWithdrawals[withdrawalHash];
// We generally want to prevent users from proving the same withdrawal multiple times
// because each successive proof will update the timestamp. A malicious user can take
// advantage of this to prevent other users from finalizing their withdrawal. However,
// since withdrawals are proven before an output root is finalized, we need to allow users
// to re-prove their withdrawal only in the case that the output root for their specified
// output index has been updated.
require(
provenWithdrawal.timestamp == 0
|| l2Oracle.getL2Output(provenWithdrawal.l2OutputIndex).outputRoot != provenWithdrawal.outputRoot,
|| l2Oracle.getL2Output(provenWithdrawal.l2OutputIndex).outputRoot != provenWithdrawal.outputRoot,
"OptimismPortal: withdrawal hash has already been proven"
);
// Compute the storage slot of the withdrawal hash in the L2ToL1MessagePasser contract.
// Refer to the Solidity documentation for more information on how storage layouts are
// computed for mappings.
bytes32 storageKey = keccak256(
abi.encode(
withdrawalHash,
uint256(0) // The withdrawals mapping is at the first slot in the layout.
)
);
// Verify that the hash of this withdrawal was stored in the L2toL1MessagePasser contract
// on L2. If this is true, under the assumption that the SecureMerkleTrie does not have
// bugs, then we know that this withdrawal was actually triggered on L2 and can therefore
// be relayed on L1.
require(
SecureMerkleTrie.verifyInclusionProof({
_key: abi.encode(storageKey),
_key: abi.encode(withdrawalHash),
_value: hex"01",
_proof: _withdrawalProof,
_root: _outputRootProof.messagePasserStorageRoot
......@@ -302,63 +478,6 @@ contract OptimismPortal is Initializable, ResourceMetering, ISemver {
timestamp: uint128(block.timestamp),
l2OutputIndex: uint128(_l2OutputIndex)
});
// Emit a `WithdrawalProven` event.
emit WithdrawalProven(withdrawalHash, _tx.sender, _tx.target);
}
/// @notice Finalizes a withdrawal transaction.
/// @param _tx Withdrawal transaction to finalize.
function finalizeWithdrawalTransaction(Types.WithdrawalTransaction memory _tx) external whenNotPaused {
// Make sure that the l2Sender has not yet been set. The l2Sender is set to a value other
// than the default value when a withdrawal transaction is being finalized. This check is
// a defacto reentrancy guard.
if (l2Sender != Constants.DEFAULT_L2_SENDER) revert NonReentrant();
// Grab the proven withdrawal from the `provenWithdrawals` map.
bytes32 withdrawalHash = Hashing.hashWithdrawal(_tx);
ProvenWithdrawal memory provenWithdrawal = provenWithdrawals[withdrawalHash];
// A withdrawal can only be finalized if it has been proven. We know that a withdrawal has
// been proven at least once when its timestamp is non-zero. Unproven withdrawals will have
// a timestamp of zero.
require(provenWithdrawal.timestamp != 0, "OptimismPortal: withdrawal has not been proven yet");
// As a sanity check, we make sure that the proven withdrawal's timestamp is greater than
// starting timestamp inside the L2OutputOracle. Not strictly necessary but extra layer of
// safety against weird bugs in the proving step.
require(
provenWithdrawal.timestamp >= l2Oracle.startingTimestamp(),
"OptimismPortal: withdrawal timestamp less than L2 Oracle starting timestamp"
);
// A proven withdrawal must wait at least the finalization period before it can be
// finalized. This waiting period can elapse in parallel with the waiting period for the
// output the withdrawal was proven against. In effect, this means that the minimum
// withdrawal time is proposal submission time + finalization period.
require(
_isFinalizationPeriodElapsed(provenWithdrawal.timestamp),
"OptimismPortal: proven withdrawal finalization period has not elapsed"
);
// Grab the OutputProposal from the L2OutputOracle, will revert if the output that
// corresponds to the given index has not been proposed yet.
Types.OutputProposal memory proposal = l2Oracle.getL2Output(provenWithdrawal.l2OutputIndex);
// Check that the output root that was used to prove the withdrawal is the same as the
// current output root for the given output index. An output root may change if it is
// deleted by the challenger address and then re-proposed.
require(
proposal.outputRoot == provenWithdrawal.outputRoot,
"OptimismPortal: output root proven is not the same as current output root"
);
// Check that the output proposal has also been finalized.
require(
_isFinalizationPeriodElapsed(proposal.timestamp),
"OptimismPortal: output proposal finalization period has not elapsed"
);
// Check that this withdrawal has not already been finalized, this is replay protection.
require(finalizedWithdrawals[withdrawalHash] == false, "OptimismPortal: withdrawal has already been finalized");
......@@ -367,29 +486,22 @@ contract OptimismPortal is Initializable, ResourceMetering, ISemver {
// Set the l2Sender so contracts know who triggered this withdrawal on L2.
// This acts as a reentrancy guard.
l2Sender = _tx.sender;
l2Sender = msg.sender;
bool success;
(address token,) = gasPayingToken();
if (token == Constants.ETHER) {
// Trigger the call to the target contract. We use a custom low level method
// SafeCall.callWithMinGas to ensure two key properties
// 1. Target contracts cannot force this call to run out of gas by returning a very large
// amount of data (and this is OK because we don't care about the returndata here).
// 2. The amount of gas provided to the execution context of the target is at least the
// gas limit specified by the user. If there is not enough gas in the current context
// to accomplish this, `callWithMinGas` will revert.
success = SafeCall.callWithMinGas(_tx.target, _tx.gasLimit, _tx.value, _tx.data);
success = SafeCall.send(_param.user, _param.value);
} else {
// Cannot call the token contract directly from the portal. This would allow an attacker
// to call approve from a withdrawal and drain the balance of the portal.
if (_tx.target == token) revert BadTarget();
if (_param.user == token) revert BadTarget();
// Only transfer value when a non zero value is specified. This saves gas in the case of
// using the standard bridge or arbitrary message passing.
if (_tx.value != 0) {
if (_param.value != 0) {
// Update the contracts internal accounting of the amount of native asset in L2.
_balance -= _tx.value;
_balance -= _param.value;
// Read the balance of the target contract before the transfer so the consistency
// of the transfer can be checked afterwards.
......@@ -398,20 +510,16 @@ contract OptimismPortal is Initializable, ResourceMetering, ISemver {
// Transfer the ERC20 balance to the target, accounting for non standard ERC20
// implementations that may not return a boolean. This reverts if the low level
// call is not successful.
IERC20(token).safeTransfer({ to: _tx.target, value: _tx.value });
IERC20(token).safeTransfer({ to: _param.user, value: _param.value });
// The balance must be transferred exactly.
if (IERC20(token).balanceOf(address(this)) != startBalance - _tx.value) {
if (IERC20(token).balanceOf(address(this)) != startBalance - _param.value) {
revert TransferFailed();
}
}
// Make a call to the target contract only if there is calldata.
if (_tx.data.length != 0) {
success = SafeCall.callWithMinGas(_tx.target, _tx.gasLimit, 0, _tx.data);
} else {
success = true;
}
success = true;
}
// Reset the l2Sender back to the default value.
......@@ -420,12 +528,31 @@ contract OptimismPortal is Initializable, ResourceMetering, ISemver {
// All withdrawals are immediately finalized. Replayability can
// be achieved through contracts built on top of this contract
emit WithdrawalFinalized(withdrawalHash, success);
}
/// @notice withdrawal for multi users.
/// @param _params Withdrawal param to execute.
/// @param _l2OutputIndex L2 output index to prove against.
/// @param _outputRootProof Inclusion proof of the withdrawal's storage root.
function batchExChainWithdrawal(
Types.BatchExChainWithdrawalParam [] memory _params,
uint256 _l2OutputIndex,
Types.OutputRootProof calldata _outputRootProof
)
external
whenNotPaused
{
// loop _params to do exChainWithdrawal()
for (uint256 i = 0; i < _params.length; i++) {
Types.ExChainWithdrawalParam memory param;
param.coin = _params[i].coin;
param.txHash = _params[i].txHash;
param.user = _params[i].user;
param.value = _params[i].value;
bytes[] memory withdrawalProof = _params[i]._withdrawalProof;
// Reverting here is useful for determining the exact gas cost to successfully execute the
// sub call to the target contract if the minimum gas limit specified by the user would not
// be sufficient to execute the sub call.
if (success == false && tx.origin == Constants.ESTIMATION_ADDRESS) {
revert GasEstimation();
this.exChainWithdrawal(param, _l2OutputIndex, _outputRootProof, withdrawalProof);
}
}
......
......@@ -107,6 +107,13 @@ library Hashing {
return keccak256(abi.encode(_tx.nonce, _tx.sender, _tx.target, _tx.value, _tx.gasLimit, _tx.data));
}
/// @notice Derives the withdrawal hash according to the encoding in the L2.
/// @param _param Withdrawal param to hash.
/// @return Hashed withdrawal param.
function hashExChainWithdrawal(Types.ExChainWithdrawalParam memory _param) internal pure returns (bytes32) {
return keccak256(abi.encode(_param.user, _param.coin, _param.value, _param.txHash));
}
/// @notice Hashes the various elements of an output root proof into an output root hash which
/// can be used to check if the proof is valid.
/// @param _outputRootProof Output root proof which should hash to an output root.
......
......@@ -67,4 +67,19 @@ library Types {
uint256 gasLimit;
bytes data;
}
struct ExChainWithdrawalParam {
uint256 value;
address user;
bytes coin;
bytes32 txHash;
}
struct BatchExChainWithdrawalParam {
uint256 value;
address user;
bytes coin;
bytes32 txHash;
bytes[] _withdrawalProof;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment