Skip to content

Commit

Permalink
feat: remove AllowList field from transaction and message types
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Remove `AllowList` field from transaction and message types.
  • Loading branch information
danijelTxFusion committed Aug 8, 2024
1 parent 269f787 commit 0995ddf
Show file tree
Hide file tree
Showing 9 changed files with 138 additions and 175 deletions.
17 changes: 7 additions & 10 deletions accounts/smart_account_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"crypto/ecdsa"
"errors"
"fmt"
"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/crypto"
Expand Down Expand Up @@ -127,15 +126,13 @@ var PopulateTransactionECDSA TransactionBuilder = func(ctx context.Context, tx *
}

fee, err := client.EstimateFee(ensureContext(ctx), zkTypes.CallMsg{
CallMsg: ethereum.CallMsg{
From: from,
To: tx.To,
GasFeeCap: tx.GasFeeCap,
GasTipCap: tx.GasTipCap,
Value: tx.Value,
Data: tx.Data,
},
Meta: tx.Meta,
From: from,
To: tx.To,
GasFeeCap: tx.GasFeeCap,
GasTipCap: tx.GasTipCap,
Value: tx.Value,
Data: tx.Data,
Meta: tx.Meta,
})
if err != nil {
return fmt.Errorf("failed to EstimateFee: %w", err)
Expand Down
122 changes: 49 additions & 73 deletions accounts/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/core/types"
"github.com/zksync-sdk/zksync2-go/clients"
"github.com/zksync-sdk/zksync2-go/contracts/bridgehub"
"github.com/zksync-sdk/zksync2-go/contracts/l1bridge"
Expand Down Expand Up @@ -40,31 +39,27 @@ func (o *CallOpts) ToCallOpts(from common.Address) *bind.CallOpts {
// Its primary purpose is to be transformed into types.CallMsg, wherein the 'From'
// field represents the associated account.
type CallMsg struct {
To *common.Address // The address of the recipient.
Gas uint64 // If 0, the call executes with near-infinite gas.
GasPrice *big.Int // Wei <-> gas exchange ratio.
GasFeeCap *big.Int // EIP-1559 fee cap per gas.
GasTipCap *big.Int // EIP-1559 tip per gas.
Value *big.Int // Amount of wei sent along with the call.
Data []byte // Input data, usually an ABI-encoded contract method invocation
AccessList types.AccessList // EIP-2930 access list.
Meta *zkTypes.Eip712Meta // EIP-712 metadata.
To *common.Address // The address of the recipient.
Gas uint64 // If 0, the call executes with near-infinite gas.
GasPrice *big.Int // Wei <-> gas exchange ratio.
GasFeeCap *big.Int // EIP-1559 fee cap per gas.
GasTipCap *big.Int // EIP-1559 tip per gas.
Value *big.Int // Amount of wei sent along with the call.
Data []byte // Input data, usually an ABI-encoded contract method invocation
Meta *zkTypes.Eip712Meta // EIP-712 metadata.
}

func (m *CallMsg) ToCallMsg(from common.Address) zkTypes.CallMsg {
return zkTypes.CallMsg{
CallMsg: ethereum.CallMsg{
From: from,
To: m.To,
Gas: m.Gas,
GasPrice: m.GasPrice,
GasFeeCap: m.GasFeeCap,
GasTipCap: m.GasTipCap,
Value: m.Value,
Data: m.Data,
AccessList: m.AccessList,
},
Meta: m.Meta,
From: from,
To: m.To,
Gas: m.Gas,
GasPrice: m.GasPrice,
GasFeeCap: m.GasFeeCap,
GasTipCap: m.GasTipCap,
Value: m.Value,
Data: m.Data,
Meta: m.Meta,
}
}

Expand All @@ -80,8 +75,6 @@ type WithdrawalCallMsg struct {
GasPrice *big.Int // Wei <-> gas exchange ratio.
GasFeeCap *big.Int // EIP-1559 fee cap per gas.
GasTipCap *big.Int // EIP-1559 tip per gas.

AccessList types.AccessList // EIP-2930 access list.
}

func (m *WithdrawalCallMsg) ToWithdrawalCallMsg(from common.Address) clients.WithdrawalCallMsg {
Expand All @@ -95,7 +88,6 @@ func (m *WithdrawalCallMsg) ToWithdrawalCallMsg(from common.Address) clients.Wit
GasPrice: m.GasPrice,
GasFeeCap: m.GasFeeCap,
GasTipCap: m.GasTipCap,
AccessList: m.AccessList,
}
}

Expand All @@ -110,21 +102,18 @@ type TransferCallMsg struct {
GasPrice *big.Int // Wei <-> gas exchange ratio.
GasFeeCap *big.Int // EIP-1559 fee cap per gas.
GasTipCap *big.Int // EIP-1559 tip per gas.

AccessList types.AccessList // EIP-2930 access list.
}

func (m *TransferCallMsg) ToTransferCallMsg(from common.Address) clients.TransferCallMsg {
return clients.TransferCallMsg{
To: m.To,
Amount: m.Amount,
Token: m.Token,
From: from,
Gas: m.Gas,
GasPrice: m.GasPrice,
GasFeeCap: m.GasFeeCap,
GasTipCap: m.GasTipCap,
AccessList: m.AccessList,
To: m.To,
Amount: m.Amount,
Token: m.Token,
From: from,
Gas: m.Gas,
GasPrice: m.GasPrice,
GasFeeCap: m.GasFeeCap,
GasTipCap: m.GasTipCap,
}
}

Expand Down Expand Up @@ -160,8 +149,6 @@ type DepositCallMsg struct {
GasPrice *big.Int // Wei <-> gas exchange ratio.
GasFeeCap *big.Int // EIP-1559 fee cap per gas.
GasTipCap *big.Int // EIP-1559 tip per gas.

AccessList types.AccessList // EIP-2930 access list.
}

func (m *DepositCallMsg) ToDepositTransaction() DepositTransaction {
Expand Down Expand Up @@ -191,7 +178,6 @@ func (m *DepositCallMsg) ToRequestExecuteCallMsg() RequestExecuteCallMsg {
GasPrice: m.GasPrice,
GasFeeCap: m.GasFeeCap,
GasTipCap: m.GasTipCap,
AccessList: m.AccessList,
}
}

Expand Down Expand Up @@ -275,8 +261,6 @@ type RequestExecuteCallMsg struct {
GasPrice *big.Int // Wei <-> gas exchange ratio.
GasFeeCap *big.Int // EIP-1559 fee cap per gas.
GasTipCap *big.Int // EIP-1559 tip per gas.

AccessList types.AccessList // EIP-2930 access list.
}

func (m *RequestExecuteCallMsg) ToRequestExecuteTransaction() RequestExecuteTransaction {
Expand Down Expand Up @@ -375,41 +359,35 @@ type Transaction struct {
GasFeeCap *big.Int // EIP-1559 fee cap per gas.
Gas uint64 // Gas limit to set for the transaction execution.

AccessList types.AccessList // EIP-2930 access list.

ChainID *big.Int // Chain ID of the network.
Meta *zkTypes.Eip712Meta // EIP-712 metadata.
}

func (t *Transaction) ToTransaction712(from common.Address) *zkTypes.Transaction712 {
return &zkTypes.Transaction712{
Nonce: t.Nonce,
GasTipCap: t.GasTipCap,
GasFeeCap: t.GasFeeCap,
Gas: new(big.Int).SetUint64(t.Gas),
To: t.To,
Value: t.Value,
Data: t.Data,
AccessList: t.AccessList,
ChainID: t.ChainID,
From: &from,
Meta: t.Meta,
Nonce: t.Nonce,
GasTipCap: t.GasTipCap,
GasFeeCap: t.GasFeeCap,
Gas: new(big.Int).SetUint64(t.Gas),
To: t.To,
Value: t.Value,
Data: t.Data,
ChainID: t.ChainID,
From: &from,
Meta: t.Meta,
}
}

func (t *Transaction) ToCallMsg(from common.Address) zkTypes.CallMsg {
return zkTypes.CallMsg{
CallMsg: ethereum.CallMsg{
From: from,
To: t.To,
Gas: t.Gas,
GasFeeCap: t.GasFeeCap,
GasTipCap: t.GasTipCap,
Value: t.Value,
Data: t.Data,
AccessList: t.AccessList,
},
Meta: t.Meta,
From: from,
To: t.To,
Gas: t.Gas,
GasFeeCap: t.GasFeeCap,
GasTipCap: t.GasTipCap,
Value: t.Value,
Data: t.Data,
Meta: t.Meta,
}
}

Expand Down Expand Up @@ -522,14 +500,12 @@ func (t *RequestExecuteTransaction) ToCallMsg(from common.Address, opts *Transac
}
}
return zkTypes.CallMsg{
CallMsg: ethereum.CallMsg{
From: from,
To: &t.ContractAddress,
Gas: opts.GasLimit,
GasPrice: opts.GasPrice,
Value: opts.Value,
Data: t.Calldata,
},
From: from,
To: &t.ContractAddress,
Gas: opts.GasLimit,
GasPrice: opts.GasPrice,
Value: opts.Value,
Data: t.Calldata,
Meta: &zkTypes.Eip712Meta{
GasPerPubdata: utils.NewBig(t.GasPerPubdataByte.Int64()),
FactoryDeps: factoryDeps,
Expand Down
17 changes: 6 additions & 11 deletions accounts/wallet_l1.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"crypto/ecdsa"
"errors"
"fmt"
"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"
Expand Down Expand Up @@ -810,11 +809,9 @@ func (a *WalletL1) EstimateCustomBridgeDepositL2Gas(ctx context.Context, l1Bridg
}

return (*a.clientL2).EstimateL1ToL2Execute(ensureContext(ctx), zkTypes.CallMsg{
CallMsg: ethereum.CallMsg{
From: utils.ApplyL1ToL2Alias(l1BridgeAddress),
To: &l2BridgeAddress,
Data: calldata,
},
From: utils.ApplyL1ToL2Alias(l1BridgeAddress),
To: &l2BridgeAddress,
Data: calldata,
Meta: &zkTypes.Eip712Meta{
GasPerPubdata: utils.NewBig(gasPerPubdataByte.Int64()),
},
Expand Down Expand Up @@ -844,11 +841,9 @@ func (a *WalletL1) EstimateDefaultBridgeDepositL2Gas(ctx context.Context, token

if token == a.baseToken {
return (*a.clientL2).EstimateL1ToL2Execute(ensureContext(ctx), zkTypes.CallMsg{
CallMsg: ethereum.CallMsg{
From: from,
To: &to,
Value: amount,
},
From: from,
To: &to,
Value: amount,
Meta: &zkTypes.Eip712Meta{
GasPerPubdata: utils.NewBig(gasPerPubdataByte.Int64()),
},
Expand Down
19 changes: 9 additions & 10 deletions accounts/wallet_l2.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,16 +311,15 @@ func (a *WalletL2) SignTransaction(tx *zkTypes.Transaction712) ([]byte, error) {
gas = tx.Gas.Uint64()
}
preparedTx, err := a.PopulateTransaction(context.Background(), Transaction{
To: tx.To,
Data: tx.Data,
Value: tx.Value,
Nonce: tx.Nonce,
GasTipCap: tx.GasTipCap,
GasFeeCap: tx.GasFeeCap,
Gas: gas,
AccessList: tx.AccessList,
ChainID: tx.ChainID,
Meta: tx.Meta,
To: tx.To,
Data: tx.Data,
Value: tx.Value,
Nonce: tx.Nonce,
GasTipCap: tx.GasTipCap,
GasFeeCap: tx.GasFeeCap,
Gas: gas,
ChainID: tx.ChainID,
Meta: tx.Meta,
})
if err != nil {
return nil, err
Expand Down
35 changes: 18 additions & 17 deletions clients/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ type TransferCallMsg struct {
GasFeeCap *big.Int // EIP-1559 fee cap per gas.
GasTipCap *big.Int // EIP-1559 tip per gas.

AccessList types.AccessList // EIP-2930 access list.

PaymasterParams *zkTypes.PaymasterParams // The paymaster parameters.
}

Expand Down Expand Up @@ -100,17 +98,15 @@ func (m *TransferCallMsg) ToZkCallMsg() (*zkTypes.CallMsg, error) {
}

return &zkTypes.CallMsg{
CallMsg: ethereum.CallMsg{
From: m.From,
To: to,
Gas: m.Gas,
GasPrice: m.GasPrice,
GasFeeCap: m.GasFeeCap,
GasTipCap: m.GasTipCap,
Value: value,
Data: data,
},
Meta: meta,
From: m.From,
To: to,
Gas: m.Gas,
GasPrice: m.GasPrice,
GasFeeCap: m.GasFeeCap,
GasTipCap: m.GasTipCap,
Value: value,
Data: data,
Meta: meta,
}, nil
}

Expand All @@ -127,8 +123,6 @@ type WithdrawalCallMsg struct {
GasFeeCap *big.Int // EIP-1559 fee cap per gas.
GasTipCap *big.Int // EIP-1559 tip per gas.

AccessList types.AccessList // EIP-2930 access list.

PaymasterParams *zkTypes.PaymasterParams // The paymaster parameters.
}

Expand Down Expand Up @@ -195,8 +189,15 @@ func (m *WithdrawalCallMsg) ToZkCallMsg(defaultL2Bridge *common.Address) (*zkTyp
}

return &zkTypes.CallMsg{
CallMsg: *msg,
Meta: meta,
From: msg.From,
To: msg.To,
Gas: msg.Gas,
GasPrice: msg.GasPrice,
GasFeeCap: msg.GasFeeCap,
GasTipCap: msg.GasTipCap,
Value: msg.Value,
Data: msg.Data,
Meta: meta,
}, nil
}

Expand Down
Loading

0 comments on commit 0995ddf

Please sign in to comment.