Merge pull request #329 from hermeznetwork/feature/deposit-amount Rename load amount to deposit amount
jump to
@@ -13,7 +13,7 @@ PublicConstants common.RollupConstants `json:"publicConstants"`
MaxFeeIdxCoordinator int `json:"maxFeeIdxCoordinator"` ReservedIdx int `json:"reservedIdx"` ExitIdx int `json:"exitIdx"` - LimitLoadAmount *big.Int `json:"limitLoadAmount"` + LimitDepositAmount *big.Int `json:"limitDepositAmount"` LimitL2TransferAmount *big.Int `json:"limitL2TransferAmount"` LimitTokens int `json:"limitTokens"` L1CoordinatorTotalBytes int `json:"l1CoordinatorTotalBytes"`@@ -32,7 +32,7 @@ PublicConstants: publicConstants,
MaxFeeIdxCoordinator: common.RollupConstMaxFeeIdxCoordinator, ReservedIdx: common.RollupConstReservedIDx, ExitIdx: common.RollupConstExitIDx, - LimitLoadAmount: common.RollupConstLimitLoadAmount, + LimitDepositAmount: common.RollupConstLimitDepositAmount, LimitL2TransferAmount: common.RollupConstLimitL2TransferAmount, LimitTokens: common.RollupConstLimitTokens, L1CoordinatorTotalBytes: common.RollupConstL1CoordinatorTotalBytes,
@@ -1745,12 +1745,12 @@ $ref: '#/components/schemas/ToForgeL1TransactionsNum'
userOrigin: type: boolean description: True if the transaction was sent by a user. False if it was sent by a coordinator. - loadAmount: + depositAmount: allOf: - $ref: '#/components/schemas/BigInt' - description: Tokens transfered from L1 to L2. - example: "4900000000000000000" - historicLoadAmountUSD: + historicDepositAmountUSD: type: number description: Load amount in USD, at the moment the transaction was made. example: 3.897@@ -1763,8 +1763,8 @@ - example: 258723049
required: - toForgeL1TransactionsNum - userOrigin - - loadAmount - - historicLoadAmountUSD + - depositAmount + - historicDepositAmountUSD - ethereumBlockNum additionalProperties: false L2Info:@@ -1790,8 +1790,8 @@ additionalProperties: false
example: L1Info: ethereumBlockNum: 1 - historicLoadAmountUSD: 232.47 - loadAmount: '261' + historicDepositAmountUSD: 232.47 + depositAmount: '261' toForgeL1TransactionsNum: 10 userOrigin: true L1orL2: L1@@ -1854,8 +1854,8 @@ example:
transactions: - L1Info: ethereumBlockNum: 3 - historicLoadAmountUSD: - loadAmount: '0' + historicDepositAmountUSD: + depositAmount: '0' toForgeL1TransactionsNum: 7 userOrigin: true L1orL2: L1@@ -1946,8 +1946,8 @@ symbol: ETH
type: Exit - L1Info: ethereumBlockNum: 3 - historicLoadAmountUSD: 14099.9999859 - loadAmount: '33333333300000000000' + historicDepositAmountUSD: 14099.9999859 + depositAmount: '33333333300000000000' toForgeL1TransactionsNum: 2 userOrigin: true L1orL2: L1@@ -2480,7 +2480,7 @@ $ref: '#/components/schemas/PendingItems'
example: accounts: - accountIndex: hez:ETH:259 - balance: '2590000000' + balance: '2590000000000000000' bjj: hez:W6x4TZOAZ9mAqdOb3Xm_hKDLspaXfEfMMN4tXOkinS-W hezEthereumAddress: hez:0x7E5F4552091A69125d5DfCb7b8C2659029395Bdf itemId: 4@@ -2954,7 +2954,7 @@ exitIdx:
type: integer description: Account index used to indicate that a transaction is an `exit` or `force exit`. example: 1 - limitLoadAmount: + limitDepositAmount: type: integer description: Maximum load amount (L1 to L2) allowed. example: 321@@ -2972,7 +2972,7 @@ description: Number of bytes that a L1 coordinator transaction has ([4 bytes] token + [32 bytes] babyjub + [65 bytes] compressedSignature).
example: 101 l1UserTotalBytes: type: integer - description: Number of bytes that a L1 user transaction has ([20 bytes] fromEthAddr + [32 bytes] fromBjj-compressed + [6 bytes] fromIdx + [2 bytes] loadAmountFloat16 + [2 bytes] amountFloat16 + [4 bytes] tokenId + [6 bytes] toIdx). + description: Number of bytes that a L1 user transaction has ([20 bytes] fromEthAddr + [32 bytes] fromBjj-compressed + [6 bytes] fromIdx + [2 bytes] depositAmountFloat16 + [2 bytes] amountFloat16 + [4 bytes] tokenId + [6 bytes] toIdx). example: 72 maxL1UserTx: type: integer@@ -3002,7 +3002,7 @@ required:
- publicConstants - reservedIdx - exitIdx - - limitLoadAmount + - limitDepositAmount - limitL2TransferAmount - limitTokens - l1CoordinatorTotalBytes
@@ -18,11 +18,11 @@ "github.com/stretchr/testify/require"
) type testL1Info struct { - ToForgeL1TxsNum *int64 `json:"toForgeL1TransactionsNum"` - UserOrigin bool `json:"userOrigin"` - LoadAmount string `json:"loadAmount"` - HistoricLoadAmountUSD *float64 `json:"historicLoadAmountUSD"` - EthBlockNum int64 `json:"ethereumBlockNum"` + ToForgeL1TxsNum *int64 `json:"toForgeL1TransactionsNum"` + UserOrigin bool `json:"userOrigin"` + DepositAmount string `json:"depositAmount"` + HistoricDepositAmountUSD *float64 `json:"historicDepositAmountUSD"` + EthBlockNum int64 `json:"ethereumBlockNum"` } type testL2Info struct {@@ -125,7 +125,7 @@ Timestamp: getTimestamp(l1.EthBlockNum, blocks),
L1Info: &testL1Info{ ToForgeL1TxsNum: l1.ToForgeL1TxsNum, UserOrigin: l1.UserOrigin, - LoadAmount: l1.LoadAmount.String(), + DepositAmount: l1.DepositAmount.String(), EthBlockNum: l1.EthBlockNum, }, Token: token,@@ -160,11 +160,11 @@ usd := *token.USD * amountFloat / math.Pow(10, float64(token.Decimals))
if usd != 0 { tx.HistoricUSD = &usd } - laf := new(big.Float).SetInt(l1.LoadAmount) - loadAmountFloat, _ := laf.Float64() - loadUSD := *token.USD * loadAmountFloat / math.Pow(10, float64(token.Decimals)) - if loadAmountFloat != 0 { - tx.L1Info.HistoricLoadAmountUSD = &loadUSD + laf := new(big.Float).SetInt(l1.DepositAmount) + depositAmountFloat, _ := laf.Float64() + loadUSD := *token.USD * depositAmountFloat / math.Pow(10, float64(token.Decimals)) + if depositAmountFloat != 0 { + tx.L1Info.HistoricDepositAmountUSD = &loadUSD } } txs = append(txs, tx)@@ -474,7 +474,7 @@ test.AssertUSD(t, expected[i].HistoricUSD, actual[i].HistoricUSD)
if expected[i].L2Info != nil { test.AssertUSD(t, expected[i].L2Info.HistoricFeeUSD, actual[i].L2Info.HistoricFeeUSD) } else { - test.AssertUSD(t, expected[i].L1Info.HistoricLoadAmountUSD, actual[i].L1Info.HistoricLoadAmountUSD) + test.AssertUSD(t, expected[i].L1Info.HistoricDepositAmountUSD, actual[i].L1Info.HistoricDepositAmountUSD) } assert.Equal(t, expected[i], actual[i]) }
@@ -66,7 +66,7 @@ RollupConstLimitTokens = (1 << 32)
// RollupConstL1CoordinatorTotalBytes [4 bytes] token + [32 bytes] babyjub + [65 bytes] compressedSignature RollupConstL1CoordinatorTotalBytes = 101 // RollupConstL1UserTotalBytes [20 bytes] fromEthAddr + [32 bytes] fromBjj-compressed + [6 bytes] fromIdx + - // [2 bytes] loadAmountFloat16 + [2 bytes] amountFloat16 + [4 bytes] tokenId + [6 bytes] toIdx + // [2 bytes] depositAmountFloat16 + [2 bytes] amountFloat16 + [4 bytes] tokenId + [6 bytes] toIdx RollupConstL1UserTotalBytes = 72 // RollupConstMaxL1UserTx Maximum L1-user transactions allowed to be queued in a batch RollupConstMaxL1UserTx = 128@@ -87,8 +87,8 @@ LenVerifiers = 1
) var ( - // RollupConstLimitLoadAmount Max load amount allowed (loadAmount: L1 --> L2) - RollupConstLimitLoadAmount, _ = new(big.Int).SetString("340282366920938463463374607431768211456", 10) + // RollupConstLimitDepositAmount Max load amount allowed (depositAmount: L1 --> L2) + RollupConstLimitDepositAmount, _ = new(big.Int).SetString("340282366920938463463374607431768211456", 10) // RollupConstLimitL2TransferAmount Max amount allowed (amount L2 --> L2) RollupConstLimitL2TransferAmount, _ = new(big.Int).SetString("6277101735386680763835789423207666416102355444464034512896", 10)
@@ -32,7 +32,7 @@ TxID TxID `meddler:"id"`
ToForgeL1TxsNum *int64 `meddler:"to_forge_l1_txs_num"` // toForgeL1TxsNum in which the tx was forged / will be forged Position int `meddler:"position"` UserOrigin bool `meddler:"user_origin"` // true if the tx was originated by a user, false if it was aoriginated by a coordinator. Note that this differ from the spec for implementation simplification purpposes - FromIdx Idx `meddler:"from_idx,zeroisnull"` // FromIdx is used by L1Tx/Deposit to indicate the Idx receiver of the L1Tx.LoadAmount (deposit) + FromIdx Idx `meddler:"from_idx,zeroisnull"` // FromIdx is used by L1Tx/Deposit to indicate the Idx receiver of the L1Tx.DepositAmount (deposit) FromEthAddr ethCommon.Address `meddler:"from_eth_addr,zeroisnull"` FromBJJ *babyjub.PublicKey `meddler:"from_bjj,zeroisnull"` ToIdx Idx `meddler:"to_idx"` // ToIdx is ignored in L1Tx/Deposit, but used in the L1Tx/DepositAndTransfer@@ -40,12 +40,12 @@ TokenID TokenID `meddler:"token_id"`
Amount *big.Int `meddler:"amount,bigint"` // EffectiveAmount only applies to L1UserTx. EffectiveAmount *big.Int `meddler:"effective_amount,bigintnull"` - LoadAmount *big.Int `meddler:"load_amount,bigint"` - // EffectiveLoadAmount only applies to L1UserTx. - EffectiveLoadAmount *big.Int `meddler:"effective_load_amount,bigintnull"` - EthBlockNum int64 `meddler:"eth_block_num"` // Ethereum Block Number in which this L1Tx was added to the queue - Type TxType `meddler:"type"` - BatchNum *BatchNum `meddler:"batch_num"` + DepositAmount *big.Int `meddler:"deposit_amount,bigint"` + // EffectiveDepositAmount only applies to L1UserTx. + EffectiveDepositAmount *big.Int `meddler:"effective_deposit_amount,bigintnull"` + EthBlockNum int64 `meddler:"eth_block_num"` // Ethereum Block Number in which this L1Tx was added to the queue + Type TxType `meddler:"type"` + BatchNum *BatchNum `meddler:"batch_num"` } // NewL1Tx returns the given L1Tx with the TxId & Type parameters calculated@@ -67,7 +67,7 @@ txType = TxTypeDeposit
} else if l1Tx.ToIdx == Idx(1) { txType = TxTypeForceExit } else if l1Tx.ToIdx >= IdxUserThreshold { - if l1Tx.LoadAmount.Int64() == int64(0) { + if l1Tx.DepositAmount.Int64() == int64(0) { txType = TxTypeForceTransfer } else { txType = TxTypeDepositTransfer@@ -140,13 +140,13 @@ ToForgeL1TxsNum: tx.ToForgeL1TxsNum,
UserOrigin: userOrigin, FromEthAddr: tx.FromEthAddr, FromBJJ: tx.FromBJJ, - LoadAmount: tx.EffectiveLoadAmount, + DepositAmount: tx.EffectiveDepositAmount, EthBlockNum: tx.EthBlockNum, } - if tx.LoadAmount != nil { - lf := new(big.Float).SetInt(tx.LoadAmount) - loadAmountFloat, _ := lf.Float64() - genericTx.LoadAmountFloat = &loadAmountFloat + if tx.DepositAmount != nil { + lf := new(big.Float).SetInt(tx.DepositAmount) + depositAmountFloat, _ := lf.Float64() + genericTx.DepositAmountFloat = &depositAmountFloat } return genericTx }@@ -257,11 +257,11 @@ if err != nil {
return nil, tracerr.Wrap(err) } copy(b[52:58], fromIdxBytes[:]) - loadAmountFloat16, err := NewFloat16(tx.LoadAmount) + depositAmountFloat16, err := NewFloat16(tx.DepositAmount) if err != nil { return nil, tracerr.Wrap(err) } - copy(b[58:60], loadAmountFloat16.Bytes()) + copy(b[58:60], depositAmountFloat16.Bytes()) amountFloat16, err := NewFloat16(tx.Amount) if err != nil { return nil, tracerr.Wrap(err)@@ -328,7 +328,7 @@ if err != nil {
return nil, tracerr.Wrap(err) } tx.FromIdx = fromIdx - tx.LoadAmount = Float16FromBytes(b[58:60]).BigInt() + tx.DepositAmount = Float16FromBytes(b[58:60]).BigInt() tx.Amount = Float16FromBytes(b[60:62]).BigInt() tx.TokenID, err = TokenIDFromBytes(b[62:66]) if err != nil {@@ -375,7 +375,7 @@ if err != nil {
return nil, tracerr.Wrap(err) } tx.Amount = big.NewInt(0) - tx.LoadAmount = big.NewInt(0) + tx.DepositAmount = big.NewInt(0) if int(v) > 0 { // L1CoordinatorTX ETH // Ethereum adds 27 to v
@@ -24,7 +24,7 @@ UserOrigin: true,
ToIdx: 301, TokenID: 5, Amount: big.NewInt(1), - LoadAmount: big.NewInt(2), + DepositAmount: big.NewInt(2), FromIdx: Idx(300), } l1Tx, err := NewL1Tx(l1Tx)@@ -35,14 +35,14 @@
func TestNewL1CoordinatorTx(t *testing.T) { batchNum := BatchNum(51966) l1Tx := &L1Tx{ - Position: 88, - UserOrigin: false, - ToIdx: 301, - TokenID: 5, - Amount: big.NewInt(1), - LoadAmount: big.NewInt(2), - FromIdx: Idx(300), - BatchNum: &batchNum, + Position: 88, + UserOrigin: false, + ToIdx: 301, + TokenID: 5, + Amount: big.NewInt(1), + DepositAmount: big.NewInt(2), + FromIdx: Idx(300), + BatchNum: &batchNum, } l1Tx, err := NewL1Tx(l1Tx) assert.Nil(t, err)@@ -124,14 +124,14 @@ pk, err := pkComp.Decompress()
require.Nil(t, err) l1Tx := &L1Tx{ - UserOrigin: true, - ToIdx: 3, - TokenID: 5, - Amount: big.NewInt(1), - LoadAmount: big.NewInt(2), - FromIdx: 2, - FromBJJ: pk, - FromEthAddr: ethCommon.HexToAddress("0xc58d29fA6e86E4FAe04DDcEd660d45BCf3Cb2370"), + UserOrigin: true, + ToIdx: 3, + TokenID: 5, + Amount: big.NewInt(1), + DepositAmount: big.NewInt(2), + FromIdx: 2, + FromBJJ: pk, + FromEthAddr: ethCommon.HexToAddress("0xc58d29fA6e86E4FAe04DDcEd660d45BCf3Cb2370"), } encodedData, err := l1Tx.BytesUser()@@ -164,17 +164,17 @@
pk, err := pkComp.Decompress() require.Nil(t, err) - loadAmount := new(big.Int) - loadAmount.SetString("100000000000000000000", 10) + depositAmount := new(big.Int) + depositAmount.SetString("100000000000000000000", 10) l1Tx := &L1Tx{ - ToIdx: 87865485, - TokenID: 2098076, - Amount: big.NewInt(2400000000000000000), - LoadAmount: loadAmount, - FromIdx: Idx(29767899), - FromBJJ: pk, - FromEthAddr: ethCommon.HexToAddress("0x85dab5b9e2e361d0c208d77be90efcc0439b0a53"), - UserOrigin: true, + ToIdx: 87865485, + TokenID: 2098076, + Amount: big.NewInt(2400000000000000000), + DepositAmount: depositAmount, + FromIdx: Idx(29767899), + FromBJJ: pk, + FromEthAddr: ethCommon.HexToAddress("0x85dab5b9e2e361d0c208d77be90efcc0439b0a53"), + UserOrigin: true, } expected, err := utils.HexDecode("85dab5b9e2e361d0c208d77be90efcc0439b0a530dd02deb2c81068e7a0f7e327df80b4ab79ee1f41a7def613e73a20c32eece5a000001c638db8be880f00020039c0000053cb88d")@@ -227,11 +227,11 @@ v := int(signature[64])
signature[64] = byte(v + 27) l1Tx := &L1Tx{ - TokenID: 231, - FromBJJ: pk, - FromEthAddr: fromEthAddr, - Amount: big.NewInt(0), - LoadAmount: big.NewInt(0), + TokenID: 231, + FromBJJ: pk, + FromEthAddr: fromEthAddr, + Amount: big.NewInt(0), + DepositAmount: big.NewInt(0), } bytesCoordinatorL1, err := l1Tx.BytesCoordinatorTx(signature)
@@ -33,8 +33,8 @@ State PoolL2TxState `meddler:"state"`
Signature babyjub.SignatureComp `meddler:"signature"` // tx signature Timestamp time.Time `meddler:"timestamp,utctime"` // time when added to the tx pool // Stored in DB: optional fileds, may be uninitialized - RqFromIdx Idx `meddler:"rq_from_idx,zeroisnull"` // FromIdx is used by L1Tx/Deposit to indicate the Idx receiver of the L1Tx.LoadAmount (deposit) - RqToIdx Idx `meddler:"rq_to_idx,zeroisnull"` // FromIdx is used by L1Tx/Deposit to indicate the Idx receiver of the L1Tx.LoadAmount (deposit) + RqFromIdx Idx `meddler:"rq_from_idx,zeroisnull"` // FromIdx is used by L1Tx/Deposit to indicate the Idx receiver of the L1Tx.DepositAmount (deposit) + RqToIdx Idx `meddler:"rq_to_idx,zeroisnull"` // FromIdx is used by L1Tx/Deposit to indicate the Idx receiver of the L1Tx.DepositAmount (deposit) RqToEthAddr ethCommon.Address `meddler:"rq_to_eth_addr,zeroisnull"` RqToBJJ *babyjub.PublicKey `meddler:"rq_to_bjj"` // TODO: stop using json, use scanner/valuer RqTokenID TokenID `meddler:"rq_token_id,zeroisnull"`
@@ -140,13 +140,13 @@ USD *float64 `meddler:"amount_usd"`
BatchNum *BatchNum `meddler:"batch_num"` // batchNum in which this tx was forged. If the tx is L2, this must be != 0 EthBlockNum int64 `meddler:"eth_block_num"` // Ethereum Block Number in which this L1Tx was added to the queue // L1 - ToForgeL1TxsNum *int64 `meddler:"to_forge_l1_txs_num"` // toForgeL1TxsNum in which the tx was forged / will be forged - UserOrigin *bool `meddler:"user_origin"` // true if the tx was originated by a user, false if it was aoriginated by a coordinator. Note that this differ from the spec for implementation simplification purpposes - FromEthAddr ethCommon.Address `meddler:"from_eth_addr"` - FromBJJ *babyjub.PublicKey `meddler:"from_bjj"` - LoadAmount *big.Int `meddler:"load_amount,bigintnull"` - LoadAmountFloat *float64 `meddler:"load_amount_f"` - LoadAmountUSD *float64 `meddler:"load_amount_usd"` + ToForgeL1TxsNum *int64 `meddler:"to_forge_l1_txs_num"` // toForgeL1TxsNum in which the tx was forged / will be forged + UserOrigin *bool `meddler:"user_origin"` // true if the tx was originated by a user, false if it was aoriginated by a coordinator. Note that this differ from the spec for implementation simplification purpposes + FromEthAddr ethCommon.Address `meddler:"from_eth_addr"` + FromBJJ *babyjub.PublicKey `meddler:"from_bjj"` + DepositAmount *big.Int `meddler:"deposit_amount,bigintnull"` + DepositAmountFloat *float64 `meddler:"deposit_amount_f"` + DepositAmountUSD *float64 `meddler:"deposit_amount_usd"` // L2 Fee *FeeSelector `meddler:"fee"` FeeUSD *float64 `meddler:"fee_usd"`@@ -165,7 +165,7 @@ }
if tx.Type == TxTypeDeposit || tx.Type == TxTypeDepositTransfer || tx.Type == TxTypeCreateAccountDepositTransfer { - fmt.Fprintf(buf, "LoadAmount: %d, ", tx.LoadAmount) + fmt.Fprintf(buf, "DepositAmount: %d, ", tx.DepositAmount) } if tx.Type != TxTypeDeposit { fmt.Fprintf(buf, "Amount: %s, ", tx.Amount)@@ -193,7 +193,7 @@ FromBJJ: tx.FromBJJ,
ToIdx: tx.ToIdx, TokenID: tx.TokenID, Amount: tx.Amount, - LoadAmount: tx.LoadAmount, + DepositAmount: tx.DepositAmount, EthBlockNum: tx.EthBlockNum, Type: tx.Type, BatchNum: tx.BatchNum,
@@ -106,8 +106,8 @@ // Txs/L1Txs
// // NewAccount boolean (0/1) flag set 'true' when L1 tx creates a new account (fromIdx==0) NewAccount []*big.Int `json:"newAccount"` // bool, len: [nTx] - // LoadAmountF encoded as float16 - LoadAmountF []*big.Int `json:"loadAmountF"` // uint16, len: [nTx] + // DepositAmountF encoded as float16 + DepositAmountF []*big.Int `json:"loadAmountF"` // uint16, len: [nTx] // FromEthAddr FromEthAddr []*big.Int `json:"fromEthAddr"` // ethCommon.Address, len: [nTx] // FromBJJCompressed boolean encoded where each value is a *big.Int@@ -310,7 +310,7 @@ zki.OnChain = newSlice(nTx)
zki.NewAccount = newSlice(nTx) // L1 - zki.LoadAmountF = newSlice(nTx) + zki.DepositAmountF = newSlice(nTx) zki.FromEthAddr = newSlice(nTx) zki.FromBJJCompressed = make([][256]*big.Int, nTx) for i := 0; i < len(zki.FromBJJCompressed); i++ {
@@ -767,23 +767,23 @@ )
return db.SlicePtrsToSlice(accs).([]common.Account), tracerr.Wrap(err) } -// AddL1Txs inserts L1 txs to the DB. USD and LoadAmountUSD will be set automatically before storing the tx. +// AddL1Txs inserts L1 txs to the DB. USD and DepositAmountUSD will be set automatically before storing the tx. // If the tx is originated by a coordinator, BatchNum must be provided. If it's originated by a user, // BatchNum should be null, and the value will be setted by a trigger when a batch forges the tx. -// EffectiveAmount and EffectiveLoadAmount are seted with default values by the DB. +// EffectiveAmount and EffectiveDepositAmount are seted with default values by the DB. func (hdb *HistoryDB) AddL1Txs(l1txs []common.L1Tx) error { return hdb.addL1Txs(hdb.db, l1txs) } -// addL1Txs inserts L1 txs to the DB. USD and LoadAmountUSD will be set automatically before storing the tx. +// addL1Txs inserts L1 txs to the DB. USD and DepositAmountUSD will be set automatically before storing the tx. // If the tx is originated by a coordinator, BatchNum must be provided. If it's originated by a user, // BatchNum should be null, and the value will be setted by a trigger when a batch forges the tx. -// EffectiveAmount and EffectiveLoadAmount are seted with default values by the DB. +// EffectiveAmount and EffectiveDepositAmount are seted with default values by the DB. func (hdb *HistoryDB) addL1Txs(d meddler.DB, l1txs []common.L1Tx) error { txs := []txWrite{} for i := 0; i < len(l1txs); i++ { af := new(big.Float).SetInt(l1txs[i].Amount) amountFloat, _ := af.Float64() - laf := new(big.Float).SetInt(l1txs[i].LoadAmount) - loadAmountFloat, _ := laf.Float64() + laf := new(big.Float).SetInt(l1txs[i].DepositAmount) + depositAmountFloat, _ := laf.Float64() txs = append(txs, txWrite{ // Generic IsL1: true,@@ -798,12 +798,12 @@ TokenID: l1txs[i].TokenID,
BatchNum: l1txs[i].BatchNum, EthBlockNum: l1txs[i].EthBlockNum, // L1 - ToForgeL1TxsNum: l1txs[i].ToForgeL1TxsNum, - UserOrigin: &l1txs[i].UserOrigin, - FromEthAddr: &l1txs[i].FromEthAddr, - FromBJJ: l1txs[i].FromBJJ, - LoadAmount: l1txs[i].LoadAmount, - LoadAmountFloat: &loadAmountFloat, + ToForgeL1TxsNum: l1txs[i].ToForgeL1TxsNum, + UserOrigin: &l1txs[i].UserOrigin, + FromEthAddr: &l1txs[i].FromEthAddr, + FromBJJ: l1txs[i].FromBJJ, + DepositAmount: l1txs[i].DepositAmount, + DepositAmountFloat: &depositAmountFloat, }) } return hdb.addTxs(d, txs)@@ -857,8 +857,8 @@ to_forge_l1_txs_num,
user_origin, from_eth_addr, from_bjj, - load_amount, - load_amount_f, + deposit_amount, + deposit_amount_f, fee, nonce ) VALUES %s;`,@@ -887,7 +887,7 @@ hez_idx(tx.from_idx, token.symbol) AS from_idx, tx.from_eth_addr, tx.from_bjj,
hez_idx(tx.to_idx, token.symbol) AS to_idx, tx.to_eth_addr, tx.to_bjj, tx.amount, tx.token_id, tx.amount_usd, tx.batch_num, tx.eth_block_num, tx.to_forge_l1_txs_num, tx.user_origin, - tx.load_amount, tx.load_amount_usd, tx.fee, tx.fee_usd, tx.nonce, + tx.deposit_amount, tx.deposit_amount_usd, tx.fee, tx.fee_usd, tx.nonce, token.token_id, token.item_id AS token_item_id, token.eth_block_num AS token_block, token.eth_addr, token.name, token.symbol, token.decimals, token.usd, token.usd_update, block.timestamp@@ -916,7 +916,7 @@ hez_idx(tx.from_idx, token.symbol) AS from_idx, tx.from_eth_addr, tx.from_bjj,
hez_idx(tx.to_idx, token.symbol) AS to_idx, tx.to_eth_addr, tx.to_bjj, tx.amount, tx.token_id, tx.amount_usd, tx.batch_num, tx.eth_block_num, tx.to_forge_l1_txs_num, tx.user_origin, - tx.load_amount, tx.load_amount_usd, tx.fee, tx.fee_usd, tx.nonce, + tx.deposit_amount, tx.deposit_amount_usd, tx.fee, tx.fee_usd, tx.nonce, token.token_id, token.item_id AS token_item_id, token.eth_block_num AS token_block, token.eth_addr, token.name, token.symbol, token.decimals, token.usd, token.usd_update, block.timestamp, count(*) OVER() AS total_items@@ -1169,7 +1169,7 @@ hdb.db, &txs, // Note that '\x' gets parsed as a big.Int with value = 0
`SELECT tx.id, tx.to_forge_l1_txs_num, tx.position, tx.user_origin, tx.from_idx, tx.from_eth_addr, tx.from_bjj, tx.to_idx, tx.token_id, tx.amount, (CASE WHEN tx.batch_num IS NULL THEN NULL WHEN tx.amount_success THEN tx.amount ELSE '\x' END) AS effective_amount, - tx.load_amount, (CASE WHEN tx.batch_num IS NULL THEN NULL WHEN tx.load_amount_success THEN tx.load_amount ELSE '\x' END) AS effective_load_amount, + tx.deposit_amount, (CASE WHEN tx.batch_num IS NULL THEN NULL WHEN tx.deposit_amount_success THEN tx.deposit_amount ELSE '\x' END) AS effective_deposit_amount, tx.eth_block_num, tx.type, tx.batch_num FROM tx WHERE is_l1 = TRUE AND user_origin = TRUE;`, )@@ -1186,7 +1186,7 @@ hdb.db, &txs,
`SELECT tx.id, tx.to_forge_l1_txs_num, tx.position, tx.user_origin, tx.from_idx, tx.from_eth_addr, tx.from_bjj, tx.to_idx, tx.token_id, tx.amount, tx.amount AS effective_amount, - tx.load_amount, tx.load_amount AS effective_load_amount, + tx.deposit_amount, tx.deposit_amount AS effective_deposit_amount, tx.eth_block_num, tx.type, tx.batch_num FROM tx WHERE is_l1 = TRUE AND user_origin = FALSE;`, )@@ -1214,7 +1214,7 @@ hdb.db, &txs, // only L1 user txs can have batch_num set to null
`SELECT tx.id, tx.to_forge_l1_txs_num, tx.position, tx.user_origin, tx.from_idx, tx.from_eth_addr, tx.from_bjj, tx.to_idx, tx.token_id, tx.amount, NULL AS effective_amount, - tx.load_amount, NULL AS effective_load_amount, + tx.deposit_amount, NULL AS effective_deposit_amount, tx.eth_block_num, tx.type, tx.batch_num FROM tx WHERE batch_num IS NULL AND to_forge_l1_txs_num = $1;`, toForgeL1TxsNum,@@ -1298,16 +1298,16 @@
return tracerr.Wrap(txn.Commit()) } -// setL1UserTxEffectiveAmounts sets the EffectiveAmount and EffectiveLoadAmount +// setL1UserTxEffectiveAmounts sets the EffectiveAmount and EffectiveDepositAmount // of the given l1UserTxs (with an UPDATE) func (hdb *HistoryDB) setL1UserTxEffectiveAmounts(d sqlx.Ext, txs []common.L1Tx) error { // Effective amounts are stored as success flags in the DB, with true value by default // to reduce the amount of updates. Therefore, only amounts that became uneffective should be // updated to become false type txUpdate struct { - ID common.TxID `db:"id"` - AmountSuccess bool `db:"amount_success"` - LoadAmountSuccess bool `db:"load_amount_success"` + ID common.TxID `db:"id"` + AmountSuccess bool `db:"amount_success"` + DepositAmountSuccess bool `db:"deposit_amount_success"` } txUpdates := []txUpdate{} equal := func(a *big.Int, b *big.Int) bool {@@ -1315,23 +1315,23 @@ return a.Cmp(b) == 0
} for i := range txs { amountSuccess := equal(txs[i].Amount, txs[i].EffectiveAmount) - loadAmountSuccess := equal(txs[i].LoadAmount, txs[i].EffectiveLoadAmount) - if !amountSuccess || !loadAmountSuccess { + depositAmountSuccess := equal(txs[i].DepositAmount, txs[i].EffectiveDepositAmount) + if !amountSuccess || !depositAmountSuccess { txUpdates = append(txUpdates, txUpdate{ - ID: txs[i].TxID, - AmountSuccess: amountSuccess, - LoadAmountSuccess: loadAmountSuccess, + ID: txs[i].TxID, + AmountSuccess: amountSuccess, + DepositAmountSuccess: depositAmountSuccess, }) } } const query string = ` UPDATE tx SET amount_success = tx_update.amount_success, - load_amount_success = tx_update.load_amount_success + deposit_amount_success = tx_update.deposit_amount_success FROM (VALUES (NULL::::BYTEA, NULL::::BOOL, NULL::::BOOL), - (:id, :amount_success, :load_amount_success) - ) as tx_update (id, amount_success, load_amount_success) + (:id, :amount_success, :deposit_amount_success) + ) as tx_update (id, amount_success, deposit_amount_success) WHERE tx.id = tx_update.id ` if len(txUpdates) > 0 {@@ -1414,7 +1414,7 @@ // Add Batches
for i := range blockData.Rollup.Batches { batch := &blockData.Rollup.Batches[i] - // Set the EffectiveAmount and EffectiveLoadAmount of all the + // Set the EffectiveAmount and EffectiveDepositAmount of all the // L1UserTxs that have been forged in this batch if len(batch.L1UserTxs) > 0 { if err = hdb.setL1UserTxEffectiveAmounts(txn, batch.L1UserTxs); err != nil {
@@ -517,16 +517,16 @@ assert.Equal(t, true, dbL1Txs[8].UserOrigin)
assert.Equal(t, true, dbL1Txs[9].UserOrigin) // Load Amount - assert.Equal(t, big.NewInt(10), dbL1Txs[0].LoadAmount) - assert.Equal(t, big.NewInt(10), dbL1Txs[1].LoadAmount) - assert.Equal(t, big.NewInt(20), dbL1Txs[2].LoadAmount) - assert.Equal(t, big.NewInt(10), dbL1Txs[3].LoadAmount) - assert.Equal(t, big.NewInt(10), dbL1Txs[4].LoadAmount) - assert.Equal(t, big.NewInt(10), dbL1Txs[5].LoadAmount) - assert.Equal(t, big.NewInt(0), dbL1Txs[6].LoadAmount) - assert.Equal(t, big.NewInt(0), dbL1Txs[7].LoadAmount) - assert.Equal(t, big.NewInt(10), dbL1Txs[8].LoadAmount) - assert.Equal(t, big.NewInt(10), dbL1Txs[9].LoadAmount) + assert.Equal(t, big.NewInt(10), dbL1Txs[0].DepositAmount) + assert.Equal(t, big.NewInt(10), dbL1Txs[1].DepositAmount) + assert.Equal(t, big.NewInt(20), dbL1Txs[2].DepositAmount) + assert.Equal(t, big.NewInt(10), dbL1Txs[3].DepositAmount) + assert.Equal(t, big.NewInt(10), dbL1Txs[4].DepositAmount) + assert.Equal(t, big.NewInt(10), dbL1Txs[5].DepositAmount) + assert.Equal(t, big.NewInt(0), dbL1Txs[6].DepositAmount) + assert.Equal(t, big.NewInt(0), dbL1Txs[7].DepositAmount) + assert.Equal(t, big.NewInt(10), dbL1Txs[8].DepositAmount) + assert.Equal(t, big.NewInt(10), dbL1Txs[9].DepositAmount) // Check saved txID's batch_num is not nil assert.Equal(t, txID, dbL1Txs[len(dbL1Txs)-2].TxID)@@ -736,12 +736,12 @@ err = historyDB.addBatch(historyDB.db, &blocks[1].Rollup.Batches[0].Batch)
assert.NoError(t, err) require.Nil(t, err) - // Set the Effective{Amount,LoadAmount} of the L1UserTxs that are forged in the second block + // Set the Effective{Amount,DepositAmount} of the L1UserTxs that are forged in the second block l1Txs := blocks[1].Rollup.Batches[0].L1UserTxs require.Equal(t, 3, len(l1Txs)) // Change some values to test all cases l1Txs[1].EffectiveAmount = big.NewInt(0) - l1Txs[2].EffectiveLoadAmount = big.NewInt(0) + l1Txs[2].EffectiveDepositAmount = big.NewInt(0) l1Txs[2].EffectiveAmount = big.NewInt(0) err = historyDB.setL1UserTxEffectiveAmounts(historyDB.db, l1Txs) require.NoError(t, err)@@ -749,18 +749,18 @@
dbL1Txs, err := historyDB.GetAllL1UserTxs() require.NoError(t, err) for i, tx := range dbL1Txs { - log.Infof("%d %v %v", i, tx.EffectiveAmount, tx.EffectiveLoadAmount) + log.Infof("%d %v %v", i, tx.EffectiveAmount, tx.EffectiveDepositAmount) assert.NotNil(t, tx.EffectiveAmount) - assert.NotNil(t, tx.EffectiveLoadAmount) + assert.NotNil(t, tx.EffectiveDepositAmount) switch tx.TxID { case l1Txs[0].TxID: - assert.Equal(t, l1Txs[0].LoadAmount, tx.EffectiveLoadAmount) + assert.Equal(t, l1Txs[0].DepositAmount, tx.EffectiveDepositAmount) assert.Equal(t, l1Txs[0].Amount, tx.EffectiveAmount) case l1Txs[1].TxID: - assert.Equal(t, l1Txs[1].LoadAmount, tx.EffectiveLoadAmount) + assert.Equal(t, l1Txs[1].DepositAmount, tx.EffectiveDepositAmount) assert.Equal(t, big.NewInt(0), tx.EffectiveAmount) case l1Txs[2].TxID: - assert.Equal(t, big.NewInt(0), tx.EffectiveLoadAmount) + assert.Equal(t, big.NewInt(0), tx.EffectiveDepositAmount) assert.Equal(t, big.NewInt(0), tx.EffectiveAmount) } }
@@ -32,10 +32,10 @@ HistoricUSD *float64 `meddler:"amount_usd"`
BatchNum *common.BatchNum `meddler:"batch_num"` // batchNum in which this tx was forged. If the tx is L2, this must be != 0 EthBlockNum int64 `meddler:"eth_block_num"` // Ethereum Block Number in which this L1Tx was added to the queue // L1 - ToForgeL1TxsNum *int64 `meddler:"to_forge_l1_txs_num"` // toForgeL1TxsNum in which the tx was forged / will be forged - UserOrigin *bool `meddler:"user_origin"` // true if the tx was originated by a user, false if it was aoriginated by a coordinator. Note that this differ from the spec for implementation simplification purpposes - LoadAmount *apitypes.BigIntStr `meddler:"load_amount"` - HistoricLoadAmountUSD *float64 `meddler:"load_amount_usd"` + ToForgeL1TxsNum *int64 `meddler:"to_forge_l1_txs_num"` // toForgeL1TxsNum in which the tx was forged / will be forged + UserOrigin *bool `meddler:"user_origin"` // true if the tx was originated by a user, false if it was aoriginated by a coordinator. Note that this differ from the spec for implementation simplification purpposes + DepositAmount *apitypes.BigIntStr `meddler:"deposit_amount"` + HistoricDepositAmountUSD *float64 `meddler:"deposit_amount_usd"` // L2 Fee *common.FeeSelector `meddler:"fee"` HistoricFeeUSD *float64 `meddler:"fee_usd"`@@ -93,8 +93,8 @@ jsonTx["L1orL2"] = "L1"
jsonTx["L1Info"] = map[string]interface{}{ "toForgeL1TransactionsNum": tx.ToForgeL1TxsNum, "userOrigin": tx.UserOrigin, - "loadAmount": tx.LoadAmount, - "historicLoadAmountUSD": tx.HistoricLoadAmountUSD, + "depositAmount": tx.DepositAmount, + "historicDepositAmountUSD": tx.HistoricDepositAmountUSD, "ethereumBlockNum": tx.EthBlockNum, } } else {@@ -125,12 +125,12 @@ TokenID common.TokenID `meddler:"token_id"`
BatchNum *common.BatchNum `meddler:"batch_num"` // batchNum in which this tx was forged. If the tx is L2, this must be != 0 EthBlockNum int64 `meddler:"eth_block_num"` // Ethereum Block Number in which this L1Tx was added to the queue // L1 - ToForgeL1TxsNum *int64 `meddler:"to_forge_l1_txs_num"` // toForgeL1TxsNum in which the tx was forged / will be forged - UserOrigin *bool `meddler:"user_origin"` // true if the tx was originated by a user, false if it was aoriginated by a coordinator. Note that this differ from the spec for implementation simplification purpposes - FromEthAddr *ethCommon.Address `meddler:"from_eth_addr"` - FromBJJ *babyjub.PublicKey `meddler:"from_bjj"` - LoadAmount *big.Int `meddler:"load_amount,bigintnull"` - LoadAmountFloat *float64 `meddler:"load_amount_f"` + ToForgeL1TxsNum *int64 `meddler:"to_forge_l1_txs_num"` // toForgeL1TxsNum in which the tx was forged / will be forged + UserOrigin *bool `meddler:"user_origin"` // true if the tx was originated by a user, false if it was aoriginated by a coordinator. Note that this differ from the spec for implementation simplification purpposes + FromEthAddr *ethCommon.Address `meddler:"from_eth_addr"` + FromBJJ *babyjub.PublicKey `meddler:"from_bjj"` + DepositAmount *big.Int `meddler:"deposit_amount,bigintnull"` + DepositAmountFloat *float64 `meddler:"deposit_amount_f"` // L2 Fee *common.FeeSelector `meddler:"fee"` Nonce *common.Nonce `meddler:"nonce"`
@@ -135,14 +135,14 @@ FOR EACH ROW EXECUTE PROCEDURE set_token_usd_update();
CREATE SEQUENCE tx_item_id; --- important note about "amount_success" and "load_amount_success" (only relevant to L1 user txs): +-- important note about "amount_success" and "deposit_amount_success" (only relevant to L1 user txs): -- The behaviour should be: --- When tx is not forged: amount_success = false, load_amount_success = false +-- When tx is not forged: amount_success = false, deposit_amount_success = false -- When tx is forged: -- amount_success = false if the "effective amount" is 0, else true --- load_amount_success = false if the "effective load amount" is 0, else true +-- deposit_amount_success = false if the "effective load amount" is 0, else true -- --- However, in order to reduce the amount of updates, by default amount_success and load_amount_success will be set to true (when tx is unforged) +-- However, in order to reduce the amount of updates, by default amount_success and deposit_amount_success will be set to true (when tx is unforged) -- whne they should be false. This can be worked around at a query level by checking if "batch_num IS NULL" (which indicates that the tx is unforged). CREATE TABLE tx ( -- Generic TX@@ -167,10 +167,10 @@ eth_block_num BIGINT NOT NULL REFERENCES block (eth_block_num) ON DELETE CASCADE,
-- L1 to_forge_l1_txs_num BIGINT, user_origin BOOLEAN, - load_amount BYTEA, - load_amount_success BOOLEAN NOT NULL DEFAULT true, - load_amount_f NUMERIC, - load_amount_usd NUMERIC, + deposit_amount BYTEA, + deposit_amount_success BOOLEAN NOT NULL DEFAULT true, + deposit_amount_f NUMERIC, + deposit_amount_usd NUMERIC, -- L2 fee INT, fee_usd NUMERIC,@@ -463,8 +463,8 @@ -- Validate L1 Tx
IF NEW.user_origin IS NULL OR NEW.from_eth_addr IS NULL OR NEW.from_bjj IS NULL OR - NEW.load_amount IS NULL OR - NEW.load_amount_f IS NULL OR + NEW.deposit_amount IS NULL OR + NEW.deposit_amount_f IS NULL OR (NOT NEW.user_origin AND NEW.batch_num IS NULL) THEN -- If is Coordinator L1, must include batch_num RAISE EXCEPTION 'Invalid L1 tx: %', NEW; END IF;@@ -493,8 +493,8 @@ IF NOT NEW."is_l1" AND NEW."fee" > 0 THEN
NEW."fee_usd" = (SELECT NEW."amount_usd" * fee_percentage(NEW.fee::NUMERIC)); END IF; END IF; - IF NEW."is_l1" AND NEW."load_amount_f" > 0.0 THEN - NEW."load_amount_usd" = (SELECT _value * NEW.load_amount_f); + IF NEW."is_l1" AND NEW."deposit_amount_f" > 0.0 THEN + NEW."deposit_amount_usd" = (SELECT _value * NEW.deposit_amount_f); END IF; END IF; END IF;
@@ -455,11 +455,11 @@ s.zki.ToIdx[s.i] = tx.ToIdx.BigInt()
s.zki.OnChain[s.i] = big.NewInt(1) // L1Txs - loadAmountF16, err := common.NewFloat16(tx.LoadAmount) + depositAmountF16, err := common.NewFloat16(tx.DepositAmount) if err != nil { return nil, nil, false, nil, tracerr.Wrap(err) } - s.zki.LoadAmountF[s.i] = big.NewInt(int64(loadAmountF16)) + s.zki.DepositAmountF[s.i] = big.NewInt(int64(depositAmountF16)) s.zki.FromEthAddr[s.i] = common.EthAddrToBigInt(tx.FromEthAddr) if tx.FromBJJ != nil { s.zki.FromBJJCompressed[s.i] = BJJCompressedTo256BigInts(tx.FromBJJ.Compress())@@ -660,7 +660,7 @@ func (s *StateDB) applyCreateAccount(tx *common.L1Tx) error {
account := &common.Account{ TokenID: tx.TokenID, Nonce: 0, - Balance: tx.EffectiveLoadAmount, + Balance: tx.EffectiveDepositAmount, PublicKey: tx.FromBJJ, EthAddr: tx.FromEthAddr, }@@ -676,7 +676,7 @@ if babyjub.PointCoordSign(tx.FromBJJ.X) {
s.zki.Sign1[s.i] = big.NewInt(1) } s.zki.Ay1[s.i] = tx.FromBJJ.Y - s.zki.Balance1[s.i] = tx.EffectiveLoadAmount + s.zki.Balance1[s.i] = tx.EffectiveDepositAmount s.zki.EthAddr1[s.i] = common.EthAddrToBigInt(tx.FromEthAddr) s.zki.Siblings1[s.i] = siblingsToZKInputFormat(p.Siblings) if p.IsOld0 {@@ -704,12 +704,12 @@ // applyDeposit updates the balance in the account of the depositer, if
// andTransfer parameter is set to true, the method will also apply the // Transfer of the L1Tx/DepositTransfer func (s *StateDB) applyDeposit(tx *common.L1Tx, transfer bool) error { - // deposit the tx.EffectiveLoadAmount into the sender account + // deposit the tx.EffectiveDepositAmount into the sender account accSender, err := s.GetAccount(tx.FromIdx) if err != nil { return tracerr.Wrap(err) } - accSender.Balance = new(big.Int).Add(accSender.Balance, tx.EffectiveLoadAmount) + accSender.Balance = new(big.Int).Add(accSender.Balance, tx.EffectiveDepositAmount) // in case that the tx is a L1Tx>DepositTransfer var accReceiver *common.Account@@ -883,7 +883,7 @@ func (s *StateDB) applyCreateAccountDepositTransfer(tx *common.L1Tx) error {
accSender := &common.Account{ TokenID: tx.TokenID, Nonce: 0, - Balance: tx.EffectiveLoadAmount, + Balance: tx.EffectiveDepositAmount, PublicKey: tx.FromBJJ, EthAddr: tx.FromEthAddr, }@@ -908,7 +908,7 @@ if babyjub.PointCoordSign(tx.FromBJJ.X) {
s.zki.Sign1[s.i] = big.NewInt(1) } s.zki.Ay1[s.i] = tx.FromBJJ.Y - s.zki.Balance1[s.i] = tx.EffectiveLoadAmount + s.zki.Balance1[s.i] = tx.EffectiveDepositAmount s.zki.EthAddr1[s.i] = common.EthAddrToBigInt(tx.FromEthAddr) s.zki.Siblings1[s.i] = siblingsToZKInputFormat(p.Siblings) if p.IsOld0 {@@ -1039,20 +1039,20 @@ func (s *StateDB) computeEffectiveAmounts(tx *common.L1Tx) {
if !tx.UserOrigin { // case where the L1Tx is generated by the Coordinator tx.EffectiveAmount = big.NewInt(0) - tx.EffectiveLoadAmount = big.NewInt(0) + tx.EffectiveDepositAmount = big.NewInt(0) return } tx.EffectiveAmount = tx.Amount - tx.EffectiveLoadAmount = tx.LoadAmount + tx.EffectiveDepositAmount = tx.DepositAmount if tx.Type == common.TxTypeCreateAccountDeposit { return } if tx.ToIdx >= common.UserThreshold && tx.FromIdx == common.Idx(0) { // CreateAccountDepositTransfer case - cmp := tx.LoadAmount.Cmp(tx.Amount) - if cmp == -1 { // LoadAmount<Amount + cmp := tx.DepositAmount.Cmp(tx.Amount) + if cmp == -1 { // DepositAmount<Amount tx.EffectiveAmount = big.NewInt(0) return }@@ -1061,24 +1061,24 @@ }
accSender, err := s.GetAccount(tx.FromIdx) if err != nil { - log.Debugf("EffectiveAmount & EffectiveLoadAmount = 0: can not get account for tx.FromIdx: %d", tx.FromIdx) - tx.EffectiveLoadAmount = big.NewInt(0) + log.Debugf("EffectiveAmount & EffectiveDepositAmount = 0: can not get account for tx.FromIdx: %d", tx.FromIdx) + tx.EffectiveDepositAmount = big.NewInt(0) tx.EffectiveAmount = big.NewInt(0) return } // check that tx.TokenID corresponds to the Sender account TokenID if tx.TokenID != accSender.TokenID { - log.Debugf("EffectiveAmount & EffectiveLoadAmount = 0: tx.TokenID (%d) !=sender account TokenID (%d)", tx.TokenID, accSender.TokenID) - tx.EffectiveLoadAmount = big.NewInt(0) + log.Debugf("EffectiveAmount & EffectiveDepositAmount = 0: tx.TokenID (%d) !=sender account TokenID (%d)", tx.TokenID, accSender.TokenID) + tx.EffectiveDepositAmount = big.NewInt(0) tx.EffectiveAmount = big.NewInt(0) return } // check that Sender has enough balance bal := accSender.Balance - if tx.LoadAmount != nil { - bal = new(big.Int).Add(bal, tx.EffectiveLoadAmount) + if tx.DepositAmount != nil { + bal = new(big.Int).Add(bal, tx.EffectiveDepositAmount) } cmp := bal.Cmp(tx.Amount) if cmp == -1 {@@ -1090,8 +1090,8 @@
// check that the tx.FromEthAddr is the same than the EthAddress of the // Sender if !bytes.Equal(tx.FromEthAddr.Bytes(), accSender.EthAddr.Bytes()) { - log.Debugf("EffectiveAmount & EffectiveLoadAmount = 0: tx.FromEthAddr (%s) must be the same EthAddr of the sender account by the Idx (%s)", tx.FromEthAddr.Hex(), accSender.EthAddr.Hex()) - tx.EffectiveLoadAmount = big.NewInt(0) + log.Debugf("EffectiveAmount & EffectiveDepositAmount = 0: tx.FromEthAddr (%s) must be the same EthAddr of the sender account by the Idx (%s)", tx.FromEthAddr.Hex(), accSender.EthAddr.Hex()) + tx.EffectiveDepositAmount = big.NewInt(0) tx.EffectiveAmount = big.NewInt(0) return }@@ -1104,14 +1104,14 @@
// check that TokenID is the same for Sender & Receiver account accReceiver, err := s.GetAccount(tx.ToIdx) if err != nil { - log.Debugf("EffectiveAmount & EffectiveLoadAmount = 0: can not get account for tx.ToIdx: %d", tx.ToIdx) - tx.EffectiveLoadAmount = big.NewInt(0) + log.Debugf("EffectiveAmount & EffectiveDepositAmount = 0: can not get account for tx.ToIdx: %d", tx.ToIdx) + tx.EffectiveDepositAmount = big.NewInt(0) tx.EffectiveAmount = big.NewInt(0) return } if accSender.TokenID != accReceiver.TokenID { - log.Debugf("EffectiveAmount & EffectiveLoadAmount = 0: sender account TokenID (%d) != receiver account TokenID (%d)", tx.TokenID, accSender.TokenID) - tx.EffectiveLoadAmount = big.NewInt(0) + log.Debugf("EffectiveAmount & EffectiveDepositAmount = 0: sender account TokenID (%d) != receiver account TokenID (%d)", tx.TokenID, accSender.TokenID) + tx.EffectiveDepositAmount = big.NewInt(0) tx.EffectiveAmount = big.NewInt(0) return }
@@ -58,80 +58,80 @@ _, err = sdb.ProcessTxs(ptc, nil, blocks[0].Rollup.L1UserTxs, nil, nil)
require.Nil(t, err) tx := common.L1Tx{ - FromIdx: 256, - ToIdx: 257, - Amount: big.NewInt(10), - LoadAmount: big.NewInt(0), - FromEthAddr: tc.Users["A"].Addr, - UserOrigin: true, + FromIdx: 256, + ToIdx: 257, + Amount: big.NewInt(10), + DepositAmount: big.NewInt(0), + FromEthAddr: tc.Users["A"].Addr, + UserOrigin: true, } sdb.computeEffectiveAmounts(&tx) - assert.Equal(t, big.NewInt(0), tx.EffectiveLoadAmount) + assert.Equal(t, big.NewInt(0), tx.EffectiveDepositAmount) assert.Equal(t, big.NewInt(10), tx.EffectiveAmount) // expect error due not enough funds tx = common.L1Tx{ - FromIdx: 256, - ToIdx: 257, - Amount: big.NewInt(11), - LoadAmount: big.NewInt(0), - FromEthAddr: tc.Users["A"].Addr, - UserOrigin: true, + FromIdx: 256, + ToIdx: 257, + Amount: big.NewInt(11), + DepositAmount: big.NewInt(0), + FromEthAddr: tc.Users["A"].Addr, + UserOrigin: true, } sdb.computeEffectiveAmounts(&tx) - assert.Equal(t, big.NewInt(0), tx.EffectiveLoadAmount) + assert.Equal(t, big.NewInt(0), tx.EffectiveDepositAmount) assert.Equal(t, big.NewInt(0), tx.EffectiveAmount) // expect no-error due not enough funds in a // CreateAccountDepositTransfer transction tx = common.L1Tx{ - FromIdx: 0, - ToIdx: 257, - Amount: big.NewInt(10), - LoadAmount: big.NewInt(10), - UserOrigin: true, + FromIdx: 0, + ToIdx: 257, + Amount: big.NewInt(10), + DepositAmount: big.NewInt(10), + UserOrigin: true, } sdb.computeEffectiveAmounts(&tx) - assert.Equal(t, big.NewInt(10), tx.EffectiveLoadAmount) + assert.Equal(t, big.NewInt(10), tx.EffectiveDepositAmount) assert.Equal(t, big.NewInt(10), tx.EffectiveAmount) // expect error due not enough funds in a CreateAccountDepositTransfer // transction tx = common.L1Tx{ - FromIdx: 0, - ToIdx: 257, - Amount: big.NewInt(11), - LoadAmount: big.NewInt(10), - UserOrigin: true, + FromIdx: 0, + ToIdx: 257, + Amount: big.NewInt(11), + DepositAmount: big.NewInt(10), + UserOrigin: true, } sdb.computeEffectiveAmounts(&tx) - assert.Equal(t, big.NewInt(10), tx.EffectiveLoadAmount) + assert.Equal(t, big.NewInt(10), tx.EffectiveDepositAmount) assert.Equal(t, big.NewInt(0), tx.EffectiveAmount) // expect error due not same TokenID tx = common.L1Tx{ - FromIdx: 256, - ToIdx: 258, - Amount: big.NewInt(5), - LoadAmount: big.NewInt(0), - FromEthAddr: tc.Users["A"].Addr, - UserOrigin: true, + FromIdx: 256, + ToIdx: 258, + Amount: big.NewInt(5), + DepositAmount: big.NewInt(0), + FromEthAddr: tc.Users["A"].Addr, + UserOrigin: true, } sdb.computeEffectiveAmounts(&tx) - assert.Equal(t, big.NewInt(0), tx.EffectiveLoadAmount) + assert.Equal(t, big.NewInt(0), tx.EffectiveDepositAmount) assert.Equal(t, big.NewInt(0), tx.EffectiveAmount) // expect error due not same EthAddr tx = common.L1Tx{ - FromIdx: 256, - ToIdx: 257, - Amount: big.NewInt(8), - LoadAmount: big.NewInt(0), - FromEthAddr: tc.Users["B"].Addr, - UserOrigin: true, + FromIdx: 256, + ToIdx: 257, + Amount: big.NewInt(8), + DepositAmount: big.NewInt(0), + FromEthAddr: tc.Users["B"].Addr, + UserOrigin: true, } sdb.computeEffectiveAmounts(&tx) - assert.Equal(t, big.NewInt(0), tx.EffectiveLoadAmount) + assert.Equal(t, big.NewInt(0), tx.EffectiveDepositAmount) assert.Equal(t, big.NewInt(0), tx.EffectiveAmount) }@@ -555,15 +555,15 @@ bjj0, err := common.BJJFromStringWithChecksum("21b0a1688b37f77b1d1d5539ec3b826db5ac78b2513f574a04c50a7d4f8246d7")
assert.Nil(t, err) l1Txs := []common.L1Tx{ { - FromIdx: 0, - LoadAmount: big.NewInt(16000000), - Amount: big.NewInt(0), - TokenID: 1, - FromBJJ: bjj0, - FromEthAddr: ethCommon.HexToAddress("0x7e5f4552091a69125d5dfcb7b8c2659029395bdf"), - ToIdx: 0, - Type: common.TxTypeCreateAccountDeposit, - UserOrigin: true, + FromIdx: 0, + DepositAmount: big.NewInt(16000000), + Amount: big.NewInt(0), + TokenID: 1, + FromBJJ: bjj0, + FromEthAddr: ethCommon.HexToAddress("0x7e5f4552091a69125d5dfcb7b8c2659029395bdf"), + ToIdx: 0, + Type: common.TxTypeCreateAccountDeposit, + UserOrigin: true, }, } l2Txs := []common.PoolL2Tx{@@ -611,15 +611,15 @@ assert.Equal(t, "d746824f7d0ac5044a573f51b278acb56d823bec39551d1d7bf7378b68a1b021", bjj0.String())
l1Txs := []common.L1Tx{ { - FromIdx: 0, - LoadAmount: big.NewInt(16000000), - Amount: big.NewInt(0), - TokenID: 1, - FromBJJ: bjj0, - FromEthAddr: ethCommon.HexToAddress("0x7e5f4552091a69125d5dfcb7b8c2659029395bdf"), - ToIdx: 0, - Type: common.TxTypeCreateAccountDeposit, - UserOrigin: true, + FromIdx: 0, + DepositAmount: big.NewInt(16000000), + Amount: big.NewInt(0), + TokenID: 1, + FromBJJ: bjj0, + FromEthAddr: ethCommon.HexToAddress("0x7e5f4552091a69125d5dfcb7b8c2659029395bdf"), + ToIdx: 0, + Type: common.TxTypeCreateAccountDeposit, + UserOrigin: true, }, } l2Txs := []common.PoolL2Tx{@@ -700,15 +700,15 @@ bjj0, err := common.BJJFromStringWithChecksum("21b0a1688b37f77b1d1d5539ec3b826db5ac78b2513f574a04c50a7d4f8246d7")
assert.Nil(t, err) l1Txs := []common.L1Tx{ { - FromIdx: 0, - LoadAmount: big.NewInt(16000000), - Amount: big.NewInt(0), - TokenID: 1, - FromBJJ: bjj0, - FromEthAddr: ethCommon.HexToAddress("0x7e5f4552091a69125d5dfcb7b8c2659029395bdf"), - ToIdx: 0, - Type: common.TxTypeCreateAccountDeposit, - UserOrigin: true, + FromIdx: 0, + DepositAmount: big.NewInt(16000000), + Amount: big.NewInt(0), + TokenID: 1, + FromBJJ: bjj0, + FromEthAddr: ethCommon.HexToAddress("0x7e5f4552091a69125d5dfcb7b8c2659029395bdf"), + ToIdx: 0, + Type: common.TxTypeCreateAccountDeposit, + UserOrigin: true, }, } l2Txs := []common.PoolL2Tx{@@ -778,26 +778,26 @@ assert.Nil(t, err)
l1Txs := []common.L1Tx{ { FromIdx: 0, - // LoadAmount: big.NewInt(10400), - LoadAmount: big.NewInt(16000000), - Amount: big.NewInt(0), - TokenID: 1, - FromBJJ: bjj0, - FromEthAddr: ethCommon.HexToAddress("0x7e5f4552091a69125d5dfcb7b8c2659029395bdf"), - ToIdx: 0, - Type: common.TxTypeCreateAccountDeposit, - UserOrigin: true, + // DepositAmount: big.NewInt(10400), + DepositAmount: big.NewInt(16000000), + Amount: big.NewInt(0), + TokenID: 1, + FromBJJ: bjj0, + FromEthAddr: ethCommon.HexToAddress("0x7e5f4552091a69125d5dfcb7b8c2659029395bdf"), + ToIdx: 0, + Type: common.TxTypeCreateAccountDeposit, + UserOrigin: true, }, { - FromIdx: 0, - LoadAmount: big.NewInt(16000000), - Amount: big.NewInt(0), - TokenID: 1, - FromBJJ: bjj1, - FromEthAddr: ethCommon.HexToAddress("0x2b5ad5c4795c026514f8317c7a215e218dccd6cf"), - ToIdx: 0, - Type: common.TxTypeCreateAccountDeposit, - UserOrigin: true, + FromIdx: 0, + DepositAmount: big.NewInt(16000000), + Amount: big.NewInt(0), + TokenID: 1, + FromBJJ: bjj1, + FromEthAddr: ethCommon.HexToAddress("0x2b5ad5c4795c026514f8317c7a215e218dccd6cf"), + ToIdx: 0, + Type: common.TxTypeCreateAccountDeposit, + UserOrigin: true, }, } l2Txs := []common.PoolL2Tx{
@@ -218,8 +218,8 @@
RollupWithdrawMerkleProof(babyPubKey *babyjub.PublicKey, tokenID uint32, numExitRoot, idx int64, amount *big.Int, siblings []*big.Int, instantWithdraw bool) (*types.Transaction, error) RollupWithdrawCircuit(proofA, proofC [2]*big.Int, proofB [2][2]*big.Int, tokenID uint32, numExitRoot, idx int64, amount *big.Int, instantWithdraw bool) (*types.Transaction, error) - RollupL1UserTxERC20ETH(fromBJJ *babyjub.PublicKey, fromIdx int64, loadAmount *big.Int, amount *big.Int, tokenID uint32, toIdx int64) (*types.Transaction, error) - RollupL1UserTxERC20Permit(fromBJJ *babyjub.PublicKey, fromIdx int64, loadAmount *big.Int, amount *big.Int, tokenID uint32, toIdx int64, deadline *big.Int) (tx *types.Transaction, err error) + RollupL1UserTxERC20ETH(fromBJJ *babyjub.PublicKey, fromIdx int64, depositAmount *big.Int, amount *big.Int, tokenID uint32, toIdx int64) (*types.Transaction, error) + RollupL1UserTxERC20Permit(fromBJJ *babyjub.PublicKey, fromIdx int64, depositAmount *big.Int, amount *big.Int, tokenID uint32, toIdx int64, deadline *big.Int) (tx *types.Transaction, err error) // Governance Public Functions RollupUpdateForgeL1L2BatchTimeout(newForgeL1L2BatchTimeout int64) (*types.Transaction, error)@@ -409,7 +409,7 @@ return nil, tracerr.Wrap(errTODO)
} // RollupL1UserTxERC20ETH is the interface to call the smart contract function -func (c *RollupClient) RollupL1UserTxERC20ETH(fromBJJ *babyjub.PublicKey, fromIdx int64, loadAmount *big.Int, amount *big.Int, tokenID uint32, toIdx int64) (tx *types.Transaction, err error) { +func (c *RollupClient) RollupL1UserTxERC20ETH(fromBJJ *babyjub.PublicKey, fromIdx int64, depositAmount *big.Int, amount *big.Int, tokenID uint32, toIdx int64) (tx *types.Transaction, err error) { if tx, err = c.client.CallAuth( 0, func(ec *ethclient.Client, auth *bind.TransactOpts) (*types.Transaction, error) {@@ -423,7 +423,7 @@ babyPubKey = big.NewInt(0)
} fromIdxBig := big.NewInt(fromIdx) toIdxBig := big.NewInt(toIdx) - loadAmountF, err := common.NewFloat16(loadAmount) + depositAmountF, err := common.NewFloat16(depositAmount) if err != nil { return nil, tracerr.Wrap(err) }@@ -432,10 +432,10 @@ if err != nil {
return nil, tracerr.Wrap(err) } if tokenID == 0 { - auth.Value = loadAmount + auth.Value = depositAmount } var permit []byte - return c.hermez.AddL1Transaction(auth, babyPubKey, fromIdxBig, uint16(loadAmountF), + return c.hermez.AddL1Transaction(auth, babyPubKey, fromIdxBig, uint16(depositAmountF), uint16(amountF), tokenID, toIdxBig, permit) }, ); err != nil {@@ -445,7 +445,7 @@ return tx, nil
} // RollupL1UserTxERC20Permit is the interface to call the smart contract function -func (c *RollupClient) RollupL1UserTxERC20Permit(fromBJJ *babyjub.PublicKey, fromIdx int64, loadAmount *big.Int, amount *big.Int, tokenID uint32, toIdx int64, deadline *big.Int) (tx *types.Transaction, err error) { +func (c *RollupClient) RollupL1UserTxERC20Permit(fromBJJ *babyjub.PublicKey, fromIdx int64, depositAmount *big.Int, amount *big.Int, tokenID uint32, toIdx int64, deadline *big.Int) (tx *types.Transaction, err error) { if tx, err = c.client.CallAuth( 0, func(ec *ethclient.Client, auth *bind.TransactOpts) (*types.Transaction, error) {@@ -459,7 +459,7 @@ babyPubKey = big.NewInt(0)
} fromIdxBig := big.NewInt(fromIdx) toIdxBig := big.NewInt(toIdx) - loadAmountF, err := common.NewFloat16(loadAmount) + depositAmountF, err := common.NewFloat16(depositAmount) if err != nil { return nil, tracerr.Wrap(err) }@@ -468,7 +468,7 @@ if err != nil {
return nil, tracerr.Wrap(err) } if tokenID == 0 { - auth.Value = loadAmount + auth.Value = depositAmount } owner := c.client.account.Address spender := c.address@@ -481,7 +481,7 @@ tokenAddr := c.tokenHEZCfg.Address
digest, _ := createPermitDigest(tokenAddr, owner, spender, c.chainID, amount, nonce, deadline, tokenName) signature, _ := c.client.ks.SignHash(*c.client.account, digest) permit := createPermit(owner, spender, amount, deadline, digest, signature) - return c.hermez.AddL1Transaction(auth, babyPubKey, fromIdxBig, uint16(loadAmountF), + return c.hermez.AddL1Transaction(auth, babyPubKey, fromIdxBig, uint16(depositAmountF), uint16(amountF), tokenID, toIdxBig, permit) }, ); err != nil {
@@ -267,18 +267,18 @@ key := genKeysBjj(2)
fromIdxInt64 := int64(0) toIdxInt64 := int64(0) tokenIDUint32 := uint32(0) - loadAmount, _ := new(big.Int).SetString("1000000000000000000000", 10) + depositAmount, _ := new(big.Int).SetString("1000000000000000000000", 10) l1Tx := common.L1Tx{ - FromBJJ: key.BJJPublicKey, - FromIdx: common.Idx(fromIdxInt64), - ToIdx: common.Idx(toIdxInt64), - LoadAmount: loadAmount, - TokenID: common.TokenID(tokenIDUint32), - Amount: big.NewInt(0), + FromBJJ: key.BJJPublicKey, + FromIdx: common.Idx(fromIdxInt64), + ToIdx: common.Idx(toIdxInt64), + DepositAmount: depositAmount, + TokenID: common.TokenID(tokenIDUint32), + Amount: big.NewInt(0), } L1UserTxs = append(L1UserTxs, l1Tx) - _, err = rollupClientAux.RollupL1UserTxERC20ETH(l1Tx.FromBJJ, fromIdxInt64, l1Tx.LoadAmount, l1Tx.Amount, tokenIDUint32, toIdxInt64) + _, err = rollupClientAux.RollupL1UserTxERC20ETH(l1Tx.FromBJJ, fromIdxInt64, l1Tx.DepositAmount, l1Tx.Amount, tokenIDUint32, toIdxInt64) require.NoError(t, err) currentBlockNum, err := rollupClient.client.EthLastBlock()@@ -287,7 +287,7 @@ rollupEvents, _, err := rollupClient.RollupEventsByBlock(currentBlockNum)
require.NoError(t, err) assert.Equal(t, l1Tx.FromBJJ, rollupEvents.L1UserTx[0].L1UserTx.FromBJJ) assert.Equal(t, l1Tx.ToIdx, rollupEvents.L1UserTx[0].L1UserTx.ToIdx) - assert.Equal(t, l1Tx.LoadAmount, rollupEvents.L1UserTx[0].L1UserTx.LoadAmount) + assert.Equal(t, l1Tx.DepositAmount, rollupEvents.L1UserTx[0].L1UserTx.DepositAmount) assert.Equal(t, l1Tx.TokenID, rollupEvents.L1UserTx[0].L1UserTx.TokenID) assert.Equal(t, l1Tx.Amount, rollupEvents.L1UserTx[0].L1UserTx.Amount) assert.Equal(t, rollupClientAux.client.account.Address, rollupEvents.L1UserTx[0].L1UserTx.FromEthAddr)@@ -299,18 +299,18 @@ require.NoError(t, err)
key := genKeysBjj(1) fromIdxInt64 := int64(0) toIdxInt64 := int64(0) - loadAmount, _ := new(big.Int).SetString("1000000000000000000000", 10) + depositAmount, _ := new(big.Int).SetString("1000000000000000000000", 10) l1Tx := common.L1Tx{ - FromBJJ: key.BJJPublicKey, - FromIdx: common.Idx(fromIdxInt64), - ToIdx: common.Idx(toIdxInt64), - LoadAmount: loadAmount, - TokenID: common.TokenID(tokenHEZID), - Amount: big.NewInt(0), + FromBJJ: key.BJJPublicKey, + FromIdx: common.Idx(fromIdxInt64), + ToIdx: common.Idx(toIdxInt64), + DepositAmount: depositAmount, + TokenID: common.TokenID(tokenHEZID), + Amount: big.NewInt(0), } L1UserTxs = append(L1UserTxs, l1Tx) - _, err = rollupClientAux2.RollupL1UserTxERC20ETH(l1Tx.FromBJJ, fromIdxInt64, l1Tx.LoadAmount, l1Tx.Amount, tokenHEZID, toIdxInt64) + _, err = rollupClientAux2.RollupL1UserTxERC20ETH(l1Tx.FromBJJ, fromIdxInt64, l1Tx.DepositAmount, l1Tx.Amount, tokenHEZID, toIdxInt64) require.NoError(t, err) currentBlockNum, err := rollupClient.client.EthLastBlock()@@ -319,7 +319,7 @@ rollupEvents, _, err := rollupClient.RollupEventsByBlock(currentBlockNum)
require.NoError(t, err) assert.Equal(t, l1Tx.FromBJJ, rollupEvents.L1UserTx[0].L1UserTx.FromBJJ) assert.Equal(t, l1Tx.ToIdx, rollupEvents.L1UserTx[0].L1UserTx.ToIdx) - assert.Equal(t, l1Tx.LoadAmount, rollupEvents.L1UserTx[0].L1UserTx.LoadAmount) + assert.Equal(t, l1Tx.DepositAmount, rollupEvents.L1UserTx[0].L1UserTx.DepositAmount) assert.Equal(t, l1Tx.TokenID, rollupEvents.L1UserTx[0].L1UserTx.TokenID) assert.Equal(t, l1Tx.Amount, rollupEvents.L1UserTx[0].L1UserTx.Amount) assert.Equal(t, rollupClientAux2.client.account.Address, rollupEvents.L1UserTx[0].L1UserTx.FromEthAddr)@@ -331,18 +331,18 @@ require.NoError(t, err)
key := genKeysBjj(3) fromIdxInt64 := int64(0) toIdxInt64 := int64(0) - loadAmount, _ := new(big.Int).SetString("1000000000000000000000", 10) + depositAmount, _ := new(big.Int).SetString("1000000000000000000000", 10) l1Tx := common.L1Tx{ - FromBJJ: key.BJJPublicKey, - FromIdx: common.Idx(fromIdxInt64), - ToIdx: common.Idx(toIdxInt64), - LoadAmount: loadAmount, - TokenID: common.TokenID(tokenIDERC777), - Amount: big.NewInt(0), + FromBJJ: key.BJJPublicKey, + FromIdx: common.Idx(fromIdxInt64), + ToIdx: common.Idx(toIdxInt64), + DepositAmount: depositAmount, + TokenID: common.TokenID(tokenIDERC777), + Amount: big.NewInt(0), } L1UserTxs = append(L1UserTxs, l1Tx) - _, err = rollupClientAux.RollupL1UserTxERC20Permit(l1Tx.FromBJJ, fromIdxInt64, l1Tx.LoadAmount, l1Tx.Amount, tokenIDERC777, toIdxInt64, deadline) + _, err = rollupClientAux.RollupL1UserTxERC20Permit(l1Tx.FromBJJ, fromIdxInt64, l1Tx.DepositAmount, l1Tx.Amount, tokenIDERC777, toIdxInt64, deadline) require.NoError(t, err) currentBlockNum, err := rollupClient.client.EthLastBlock()@@ -351,7 +351,7 @@ rollupEvents, _, err := rollupClient.RollupEventsByBlock(currentBlockNum)
require.NoError(t, err) assert.Equal(t, l1Tx.FromBJJ, rollupEvents.L1UserTx[0].L1UserTx.FromBJJ) assert.Equal(t, l1Tx.ToIdx, rollupEvents.L1UserTx[0].L1UserTx.ToIdx) - assert.Equal(t, l1Tx.LoadAmount, rollupEvents.L1UserTx[0].L1UserTx.LoadAmount) + assert.Equal(t, l1Tx.DepositAmount, rollupEvents.L1UserTx[0].L1UserTx.DepositAmount) assert.Equal(t, l1Tx.TokenID, rollupEvents.L1UserTx[0].L1UserTx.TokenID) assert.Equal(t, l1Tx.Amount, rollupEvents.L1UserTx[0].L1UserTx.Amount) assert.Equal(t, rollupClientAux.client.account.Address, rollupEvents.L1UserTx[0].L1UserTx.FromEthAddr)@@ -363,18 +363,18 @@ require.NoError(t, err)
fromIdxInt64 := int64(256) toIdxInt64 := int64(0) tokenIDUint32 := uint32(0) - loadAmount, _ := new(big.Int).SetString("1000000000000000000000", 10) + depositAmount, _ := new(big.Int).SetString("1000000000000000000000", 10) l1Tx := common.L1Tx{ - FromBJJ: nil, - FromIdx: common.Idx(fromIdxInt64), - ToIdx: common.Idx(toIdxInt64), - LoadAmount: loadAmount, - TokenID: common.TokenID(tokenIDUint32), - Amount: big.NewInt(0), + FromBJJ: nil, + FromIdx: common.Idx(fromIdxInt64), + ToIdx: common.Idx(toIdxInt64), + DepositAmount: depositAmount, + TokenID: common.TokenID(tokenIDUint32), + Amount: big.NewInt(0), } L1UserTxs = append(L1UserTxs, l1Tx) - _, err = rollupClientAux.RollupL1UserTxERC20ETH(l1Tx.FromBJJ, fromIdxInt64, l1Tx.LoadAmount, l1Tx.Amount, tokenIDUint32, toIdxInt64) + _, err = rollupClientAux.RollupL1UserTxERC20ETH(l1Tx.FromBJJ, fromIdxInt64, l1Tx.DepositAmount, l1Tx.Amount, tokenIDUint32, toIdxInt64) require.NoError(t, err) currentBlockNum, err := rollupClient.client.EthLastBlock()@@ -382,7 +382,7 @@ require.NoError(t, err)
rollupEvents, _, err := rollupClient.RollupEventsByBlock(currentBlockNum) require.NoError(t, err) assert.Equal(t, l1Tx.ToIdx, rollupEvents.L1UserTx[0].L1UserTx.ToIdx) - assert.Equal(t, l1Tx.LoadAmount, rollupEvents.L1UserTx[0].L1UserTx.LoadAmount) + assert.Equal(t, l1Tx.DepositAmount, rollupEvents.L1UserTx[0].L1UserTx.DepositAmount) assert.Equal(t, l1Tx.TokenID, rollupEvents.L1UserTx[0].L1UserTx.TokenID) assert.Equal(t, l1Tx.Amount, rollupEvents.L1UserTx[0].L1UserTx.Amount) assert.Equal(t, rollupClientAux.client.account.Address, rollupEvents.L1UserTx[0].L1UserTx.FromEthAddr)@@ -393,18 +393,18 @@ rollupClientAux2, err := NewRollupClient(ethereumClientAux2, hermezRollupAddressConst, tokenHEZ)
require.NoError(t, err) fromIdxInt64 := int64(257) toIdxInt64 := int64(0) - loadAmount, _ := new(big.Int).SetString("1000000000000000000000", 10) + depositAmount, _ := new(big.Int).SetString("1000000000000000000000", 10) l1Tx := common.L1Tx{ - FromBJJ: nil, - FromIdx: common.Idx(fromIdxInt64), - ToIdx: common.Idx(toIdxInt64), - LoadAmount: loadAmount, - TokenID: common.TokenID(tokenHEZID), - Amount: big.NewInt(0), + FromBJJ: nil, + FromIdx: common.Idx(fromIdxInt64), + ToIdx: common.Idx(toIdxInt64), + DepositAmount: depositAmount, + TokenID: common.TokenID(tokenHEZID), + Amount: big.NewInt(0), } L1UserTxs = append(L1UserTxs, l1Tx) - _, err = rollupClientAux2.RollupL1UserTxERC20ETH(l1Tx.FromBJJ, fromIdxInt64, l1Tx.LoadAmount, l1Tx.Amount, tokenHEZID, toIdxInt64) + _, err = rollupClientAux2.RollupL1UserTxERC20ETH(l1Tx.FromBJJ, fromIdxInt64, l1Tx.DepositAmount, l1Tx.Amount, tokenHEZID, toIdxInt64) require.NoError(t, err) currentBlockNum, err := rollupClient.client.EthLastBlock()@@ -412,7 +412,7 @@ require.NoError(t, err)
rollupEvents, _, err := rollupClient.RollupEventsByBlock(currentBlockNum) require.NoError(t, err) assert.Equal(t, l1Tx.ToIdx, rollupEvents.L1UserTx[0].L1UserTx.ToIdx) - assert.Equal(t, l1Tx.LoadAmount, rollupEvents.L1UserTx[0].L1UserTx.LoadAmount) + assert.Equal(t, l1Tx.DepositAmount, rollupEvents.L1UserTx[0].L1UserTx.DepositAmount) assert.Equal(t, l1Tx.TokenID, rollupEvents.L1UserTx[0].L1UserTx.TokenID) assert.Equal(t, l1Tx.Amount, rollupEvents.L1UserTx[0].L1UserTx.Amount) assert.Equal(t, rollupClientAux2.client.account.Address, rollupEvents.L1UserTx[0].L1UserTx.FromEthAddr)@@ -423,17 +423,17 @@ rollupClientAux, err := NewRollupClient(ethereumClientAux, hermezRollupAddressConst, tokenHEZ)
require.NoError(t, err) fromIdxInt64 := int64(258) toIdxInt64 := int64(0) - loadAmount, _ := new(big.Int).SetString("1000000000000000000000", 10) + depositAmount, _ := new(big.Int).SetString("1000000000000000000000", 10) l1Tx := common.L1Tx{ - FromIdx: common.Idx(fromIdxInt64), - ToIdx: common.Idx(toIdxInt64), - LoadAmount: loadAmount, - TokenID: common.TokenID(tokenIDERC777), - Amount: big.NewInt(0), + FromIdx: common.Idx(fromIdxInt64), + ToIdx: common.Idx(toIdxInt64), + DepositAmount: depositAmount, + TokenID: common.TokenID(tokenIDERC777), + Amount: big.NewInt(0), } L1UserTxs = append(L1UserTxs, l1Tx) - _, err = rollupClientAux.RollupL1UserTxERC20Permit(l1Tx.FromBJJ, fromIdxInt64, l1Tx.LoadAmount, l1Tx.Amount, tokenIDERC777, toIdxInt64, deadline) + _, err = rollupClientAux.RollupL1UserTxERC20Permit(l1Tx.FromBJJ, fromIdxInt64, l1Tx.DepositAmount, l1Tx.Amount, tokenIDERC777, toIdxInt64, deadline) require.NoError(t, err) currentBlockNum, err := rollupClient.client.EthLastBlock()@@ -441,7 +441,7 @@ require.NoError(t, err)
rollupEvents, _, err := rollupClient.RollupEventsByBlock(currentBlockNum) require.NoError(t, err) assert.Equal(t, l1Tx.ToIdx, rollupEvents.L1UserTx[0].L1UserTx.ToIdx) - assert.Equal(t, l1Tx.LoadAmount, rollupEvents.L1UserTx[0].L1UserTx.LoadAmount) + assert.Equal(t, l1Tx.DepositAmount, rollupEvents.L1UserTx[0].L1UserTx.DepositAmount) assert.Equal(t, l1Tx.TokenID, rollupEvents.L1UserTx[0].L1UserTx.TokenID) assert.Equal(t, l1Tx.Amount, rollupEvents.L1UserTx[0].L1UserTx.Amount) assert.Equal(t, rollupClientAux.client.account.Address, rollupEvents.L1UserTx[0].L1UserTx.FromEthAddr)@@ -453,18 +453,18 @@ require.NoError(t, err)
fromIdxInt64 := int64(256) toIdxInt64 := int64(257) tokenIDUint32 := uint32(0) - loadAmount, _ := new(big.Int).SetString("1000000000000000000000", 10) + depositAmount, _ := new(big.Int).SetString("1000000000000000000000", 10) amount, _ := new(big.Int).SetString("100000000000000000000", 10) l1Tx := common.L1Tx{ - FromIdx: common.Idx(fromIdxInt64), - ToIdx: common.Idx(toIdxInt64), - LoadAmount: loadAmount, - TokenID: common.TokenID(tokenIDUint32), - Amount: amount, + FromIdx: common.Idx(fromIdxInt64), + ToIdx: common.Idx(toIdxInt64), + DepositAmount: depositAmount, + TokenID: common.TokenID(tokenIDUint32), + Amount: amount, } L1UserTxs = append(L1UserTxs, l1Tx) - _, err = rollupClientAux.RollupL1UserTxERC20ETH(l1Tx.FromBJJ, fromIdxInt64, l1Tx.LoadAmount, l1Tx.Amount, tokenIDUint32, toIdxInt64) + _, err = rollupClientAux.RollupL1UserTxERC20ETH(l1Tx.FromBJJ, fromIdxInt64, l1Tx.DepositAmount, l1Tx.Amount, tokenIDUint32, toIdxInt64) require.NoError(t, err) currentBlockNum, err := rollupClient.client.EthLastBlock()@@ -472,7 +472,7 @@ require.NoError(t, err)
rollupEvents, _, err := rollupClient.RollupEventsByBlock(currentBlockNum) require.NoError(t, err) assert.Equal(t, l1Tx.ToIdx, rollupEvents.L1UserTx[0].L1UserTx.ToIdx) - assert.Equal(t, l1Tx.LoadAmount, rollupEvents.L1UserTx[0].L1UserTx.LoadAmount) + assert.Equal(t, l1Tx.DepositAmount, rollupEvents.L1UserTx[0].L1UserTx.DepositAmount) assert.Equal(t, l1Tx.TokenID, rollupEvents.L1UserTx[0].L1UserTx.TokenID) assert.Equal(t, l1Tx.Amount, rollupEvents.L1UserTx[0].L1UserTx.Amount) assert.Equal(t, rollupClientAux.client.account.Address, rollupEvents.L1UserTx[0].L1UserTx.FromEthAddr)@@ -483,18 +483,18 @@ rollupClientAux2, err := NewRollupClient(ethereumClientAux2, hermezRollupAddressConst, tokenHEZ)
require.NoError(t, err) fromIdxInt64 := int64(257) toIdxInt64 := int64(258) - loadAmount, _ := new(big.Int).SetString("1000000000000000000000", 10) + depositAmount, _ := new(big.Int).SetString("1000000000000000000000", 10) amount, _ := new(big.Int).SetString("100000000000000000000", 10) l1Tx := common.L1Tx{ - FromIdx: common.Idx(fromIdxInt64), - ToIdx: common.Idx(toIdxInt64), - LoadAmount: loadAmount, - TokenID: common.TokenID(tokenHEZID), - Amount: amount, + FromIdx: common.Idx(fromIdxInt64), + ToIdx: common.Idx(toIdxInt64), + DepositAmount: depositAmount, + TokenID: common.TokenID(tokenHEZID), + Amount: amount, } L1UserTxs = append(L1UserTxs, l1Tx) - _, err = rollupClientAux2.RollupL1UserTxERC20ETH(l1Tx.FromBJJ, fromIdxInt64, l1Tx.LoadAmount, l1Tx.Amount, tokenHEZID, toIdxInt64) + _, err = rollupClientAux2.RollupL1UserTxERC20ETH(l1Tx.FromBJJ, fromIdxInt64, l1Tx.DepositAmount, l1Tx.Amount, tokenHEZID, toIdxInt64) require.NoError(t, err) currentBlockNum, err := rollupClient.client.EthLastBlock()@@ -502,7 +502,7 @@ require.NoError(t, err)
rollupEvents, _, err := rollupClient.RollupEventsByBlock(currentBlockNum) require.NoError(t, err) assert.Equal(t, l1Tx.ToIdx, rollupEvents.L1UserTx[0].L1UserTx.ToIdx) - assert.Equal(t, l1Tx.LoadAmount, rollupEvents.L1UserTx[0].L1UserTx.LoadAmount) + assert.Equal(t, l1Tx.DepositAmount, rollupEvents.L1UserTx[0].L1UserTx.DepositAmount) assert.Equal(t, l1Tx.TokenID, rollupEvents.L1UserTx[0].L1UserTx.TokenID) assert.Equal(t, l1Tx.Amount, rollupEvents.L1UserTx[0].L1UserTx.Amount) assert.Equal(t, rollupClientAux2.client.account.Address, rollupEvents.L1UserTx[0].L1UserTx.FromEthAddr)@@ -513,18 +513,18 @@ rollupClientAux, err := NewRollupClient(ethereumClientAux, hermezRollupAddressConst, tokenHEZ)
require.NoError(t, err) fromIdxInt64 := int64(258) toIdxInt64 := int64(259) - loadAmount, _ := new(big.Int).SetString("1000000000000000000000", 10) + depositAmount, _ := new(big.Int).SetString("1000000000000000000000", 10) amount, _ := new(big.Int).SetString("100000000000000000000", 10) l1Tx := common.L1Tx{ - FromIdx: common.Idx(fromIdxInt64), - ToIdx: common.Idx(toIdxInt64), - LoadAmount: loadAmount, - TokenID: common.TokenID(tokenIDERC777), - Amount: amount, + FromIdx: common.Idx(fromIdxInt64), + ToIdx: common.Idx(toIdxInt64), + DepositAmount: depositAmount, + TokenID: common.TokenID(tokenIDERC777), + Amount: amount, } L1UserTxs = append(L1UserTxs, l1Tx) - _, err = rollupClientAux.RollupL1UserTxERC20Permit(l1Tx.FromBJJ, fromIdxInt64, l1Tx.LoadAmount, l1Tx.Amount, tokenIDERC777, toIdxInt64, deadline) + _, err = rollupClientAux.RollupL1UserTxERC20Permit(l1Tx.FromBJJ, fromIdxInt64, l1Tx.DepositAmount, l1Tx.Amount, tokenIDERC777, toIdxInt64, deadline) require.NoError(t, err) currentBlockNum, err := rollupClient.client.EthLastBlock()@@ -532,7 +532,7 @@ require.NoError(t, err)
rollupEvents, _, err := rollupClient.RollupEventsByBlock(currentBlockNum) require.NoError(t, err) assert.Equal(t, l1Tx.ToIdx, rollupEvents.L1UserTx[0].L1UserTx.ToIdx) - assert.Equal(t, l1Tx.LoadAmount, rollupEvents.L1UserTx[0].L1UserTx.LoadAmount) + assert.Equal(t, l1Tx.DepositAmount, rollupEvents.L1UserTx[0].L1UserTx.DepositAmount) assert.Equal(t, l1Tx.TokenID, rollupEvents.L1UserTx[0].L1UserTx.TokenID) assert.Equal(t, l1Tx.Amount, rollupEvents.L1UserTx[0].L1UserTx.Amount) assert.Equal(t, rollupClientAux.client.account.Address, rollupEvents.L1UserTx[0].L1UserTx.FromEthAddr)@@ -544,18 +544,18 @@ require.NoError(t, err)
fromIdxInt64 := int64(256) toIdxInt64 := int64(257) tokenIDUint32 := uint32(0) - loadAmount, _ := new(big.Int).SetString("1000000000000000000000", 10) + depositAmount, _ := new(big.Int).SetString("1000000000000000000000", 10) amount, _ := new(big.Int).SetString("20000000000000000000", 10) l1Tx := common.L1Tx{ - FromIdx: common.Idx(fromIdxInt64), - ToIdx: common.Idx(toIdxInt64), - LoadAmount: loadAmount, - TokenID: common.TokenID(tokenIDUint32), - Amount: amount, + FromIdx: common.Idx(fromIdxInt64), + ToIdx: common.Idx(toIdxInt64), + DepositAmount: depositAmount, + TokenID: common.TokenID(tokenIDUint32), + Amount: amount, } L1UserTxs = append(L1UserTxs, l1Tx) - _, err = rollupClientAux.RollupL1UserTxERC20ETH(l1Tx.FromBJJ, fromIdxInt64, l1Tx.LoadAmount, l1Tx.Amount, tokenIDUint32, toIdxInt64) + _, err = rollupClientAux.RollupL1UserTxERC20ETH(l1Tx.FromBJJ, fromIdxInt64, l1Tx.DepositAmount, l1Tx.Amount, tokenIDUint32, toIdxInt64) require.NoError(t, err) currentBlockNum, err := rollupClient.client.EthLastBlock()@@ -563,7 +563,7 @@ require.NoError(t, err)
rollupEvents, _, err := rollupClient.RollupEventsByBlock(currentBlockNum) require.NoError(t, err) assert.Equal(t, l1Tx.ToIdx, rollupEvents.L1UserTx[0].L1UserTx.ToIdx) - assert.Equal(t, l1Tx.LoadAmount, rollupEvents.L1UserTx[0].L1UserTx.LoadAmount) + assert.Equal(t, l1Tx.DepositAmount, rollupEvents.L1UserTx[0].L1UserTx.DepositAmount) assert.Equal(t, l1Tx.TokenID, rollupEvents.L1UserTx[0].L1UserTx.TokenID) assert.Equal(t, l1Tx.Amount, rollupEvents.L1UserTx[0].L1UserTx.Amount) assert.Equal(t, rollupClientAux.client.account.Address, rollupEvents.L1UserTx[0].L1UserTx.FromEthAddr)@@ -574,18 +574,18 @@ rollupClientAux2, err := NewRollupClient(ethereumClientAux2, hermezRollupAddressConst, tokenHEZ)
require.NoError(t, err) fromIdxInt64 := int64(257) toIdxInt64 := int64(258) - loadAmount, _ := new(big.Int).SetString("1000000000000000000000", 10) + depositAmount, _ := new(big.Int).SetString("1000000000000000000000", 10) amount, _ := new(big.Int).SetString("30000000000000000000", 10) l1Tx := common.L1Tx{ - FromIdx: common.Idx(fromIdxInt64), - ToIdx: common.Idx(toIdxInt64), - LoadAmount: loadAmount, - TokenID: common.TokenID(tokenHEZID), - Amount: amount, + FromIdx: common.Idx(fromIdxInt64), + ToIdx: common.Idx(toIdxInt64), + DepositAmount: depositAmount, + TokenID: common.TokenID(tokenHEZID), + Amount: amount, } L1UserTxs = append(L1UserTxs, l1Tx) - _, err = rollupClientAux2.RollupL1UserTxERC20ETH(l1Tx.FromBJJ, fromIdxInt64, l1Tx.LoadAmount, l1Tx.Amount, tokenHEZID, toIdxInt64) + _, err = rollupClientAux2.RollupL1UserTxERC20ETH(l1Tx.FromBJJ, fromIdxInt64, l1Tx.DepositAmount, l1Tx.Amount, tokenHEZID, toIdxInt64) require.NoError(t, err) currentBlockNum, err := rollupClient.client.EthLastBlock()@@ -593,7 +593,7 @@ require.NoError(t, err)
rollupEvents, _, err := rollupClient.RollupEventsByBlock(currentBlockNum) require.NoError(t, err) assert.Equal(t, l1Tx.ToIdx, rollupEvents.L1UserTx[0].L1UserTx.ToIdx) - assert.Equal(t, l1Tx.LoadAmount, rollupEvents.L1UserTx[0].L1UserTx.LoadAmount) + assert.Equal(t, l1Tx.DepositAmount, rollupEvents.L1UserTx[0].L1UserTx.DepositAmount) assert.Equal(t, l1Tx.TokenID, rollupEvents.L1UserTx[0].L1UserTx.TokenID) assert.Equal(t, l1Tx.Amount, rollupEvents.L1UserTx[0].L1UserTx.Amount) assert.Equal(t, rollupClientAux2.client.account.Address, rollupEvents.L1UserTx[0].L1UserTx.FromEthAddr)@@ -604,18 +604,18 @@ rollupClientAux, err := NewRollupClient(ethereumClientAux, hermezRollupAddressConst, tokenHEZ)
require.NoError(t, err) fromIdxInt64 := int64(258) toIdxInt64 := int64(259) - loadAmount, _ := new(big.Int).SetString("1000000000000000000000", 10) + depositAmount, _ := new(big.Int).SetString("1000000000000000000000", 10) amount, _ := new(big.Int).SetString("40000000000000000000", 10) l1Tx := common.L1Tx{ - FromIdx: common.Idx(fromIdxInt64), - ToIdx: common.Idx(toIdxInt64), - LoadAmount: loadAmount, - TokenID: common.TokenID(tokenIDERC777), - Amount: amount, + FromIdx: common.Idx(fromIdxInt64), + ToIdx: common.Idx(toIdxInt64), + DepositAmount: depositAmount, + TokenID: common.TokenID(tokenIDERC777), + Amount: amount, } L1UserTxs = append(L1UserTxs, l1Tx) - _, err = rollupClientAux.RollupL1UserTxERC20Permit(l1Tx.FromBJJ, fromIdxInt64, l1Tx.LoadAmount, l1Tx.Amount, tokenIDERC777, toIdxInt64, deadline) + _, err = rollupClientAux.RollupL1UserTxERC20Permit(l1Tx.FromBJJ, fromIdxInt64, l1Tx.DepositAmount, l1Tx.Amount, tokenIDERC777, toIdxInt64, deadline) require.NoError(t, err) currentBlockNum, err := rollupClient.client.EthLastBlock()@@ -623,7 +623,7 @@ require.NoError(t, err)
rollupEvents, _, err := rollupClient.RollupEventsByBlock(currentBlockNum) require.NoError(t, err) assert.Equal(t, l1Tx.ToIdx, rollupEvents.L1UserTx[0].L1UserTx.ToIdx) - assert.Equal(t, l1Tx.LoadAmount, rollupEvents.L1UserTx[0].L1UserTx.LoadAmount) + assert.Equal(t, l1Tx.DepositAmount, rollupEvents.L1UserTx[0].L1UserTx.DepositAmount) assert.Equal(t, l1Tx.TokenID, rollupEvents.L1UserTx[0].L1UserTx.TokenID) assert.Equal(t, l1Tx.Amount, rollupEvents.L1UserTx[0].L1UserTx.Amount) assert.Equal(t, rollupClientAux.client.account.Address, rollupEvents.L1UserTx[0].L1UserTx.FromEthAddr)@@ -637,15 +637,15 @@ toIdxInt64 := int64(257)
tokenIDUint32 := uint32(0) amount, _ := new(big.Int).SetString("20000000000000000000", 10) l1Tx := common.L1Tx{ - FromIdx: common.Idx(fromIdxInt64), - ToIdx: common.Idx(toIdxInt64), - LoadAmount: big.NewInt(0), - TokenID: common.TokenID(tokenIDUint32), - Amount: amount, + FromIdx: common.Idx(fromIdxInt64), + ToIdx: common.Idx(toIdxInt64), + DepositAmount: big.NewInt(0), + TokenID: common.TokenID(tokenIDUint32), + Amount: amount, } L1UserTxs = append(L1UserTxs, l1Tx) - _, err = rollupClientAux.RollupL1UserTxERC20ETH(l1Tx.FromBJJ, fromIdxInt64, l1Tx.LoadAmount, l1Tx.Amount, tokenIDUint32, toIdxInt64) + _, err = rollupClientAux.RollupL1UserTxERC20ETH(l1Tx.FromBJJ, fromIdxInt64, l1Tx.DepositAmount, l1Tx.Amount, tokenIDUint32, toIdxInt64) require.NoError(t, err) currentBlockNum, err := rollupClient.client.EthLastBlock()@@ -653,7 +653,7 @@ require.NoError(t, err)
rollupEvents, _, err := rollupClient.RollupEventsByBlock(currentBlockNum) require.NoError(t, err) assert.Equal(t, l1Tx.ToIdx, rollupEvents.L1UserTx[0].L1UserTx.ToIdx) - assert.Equal(t, l1Tx.LoadAmount, rollupEvents.L1UserTx[0].L1UserTx.LoadAmount) + assert.Equal(t, l1Tx.DepositAmount, rollupEvents.L1UserTx[0].L1UserTx.DepositAmount) assert.Equal(t, l1Tx.TokenID, rollupEvents.L1UserTx[0].L1UserTx.TokenID) assert.Equal(t, l1Tx.Amount, rollupEvents.L1UserTx[0].L1UserTx.Amount) assert.Equal(t, rollupClientAux.client.account.Address, rollupEvents.L1UserTx[0].L1UserTx.FromEthAddr)@@ -666,15 +666,15 @@ fromIdxInt64 := int64(257)
toIdxInt64 := int64(258) amount, _ := new(big.Int).SetString("10000000000000000000", 10) l1Tx := common.L1Tx{ - FromIdx: common.Idx(fromIdxInt64), - ToIdx: common.Idx(toIdxInt64), - LoadAmount: big.NewInt(0), - TokenID: common.TokenID(tokenHEZID), - Amount: amount, + FromIdx: common.Idx(fromIdxInt64), + ToIdx: common.Idx(toIdxInt64), + DepositAmount: big.NewInt(0), + TokenID: common.TokenID(tokenHEZID), + Amount: amount, } L1UserTxs = append(L1UserTxs, l1Tx) - _, err = rollupClientAux2.RollupL1UserTxERC20ETH(l1Tx.FromBJJ, fromIdxInt64, l1Tx.LoadAmount, l1Tx.Amount, tokenHEZID, toIdxInt64) + _, err = rollupClientAux2.RollupL1UserTxERC20ETH(l1Tx.FromBJJ, fromIdxInt64, l1Tx.DepositAmount, l1Tx.Amount, tokenHEZID, toIdxInt64) require.NoError(t, err) currentBlockNum, err := rollupClient.client.EthLastBlock()@@ -682,7 +682,7 @@ require.NoError(t, err)
rollupEvents, _, err := rollupClient.RollupEventsByBlock(currentBlockNum) require.NoError(t, err) assert.Equal(t, l1Tx.ToIdx, rollupEvents.L1UserTx[0].L1UserTx.ToIdx) - assert.Equal(t, l1Tx.LoadAmount, rollupEvents.L1UserTx[0].L1UserTx.LoadAmount) + assert.Equal(t, l1Tx.DepositAmount, rollupEvents.L1UserTx[0].L1UserTx.DepositAmount) assert.Equal(t, l1Tx.TokenID, rollupEvents.L1UserTx[0].L1UserTx.TokenID) assert.Equal(t, l1Tx.Amount, rollupEvents.L1UserTx[0].L1UserTx.Amount) assert.Equal(t, rollupClientAux2.client.account.Address, rollupEvents.L1UserTx[0].L1UserTx.FromEthAddr)@@ -695,15 +695,15 @@ fromIdxInt64 := int64(259)
toIdxInt64 := int64(260) amount, _ := new(big.Int).SetString("30000000000000000000", 10) l1Tx := common.L1Tx{ - FromIdx: common.Idx(fromIdxInt64), - ToIdx: common.Idx(toIdxInt64), - LoadAmount: big.NewInt(0), - TokenID: common.TokenID(tokenIDERC777), - Amount: amount, + FromIdx: common.Idx(fromIdxInt64), + ToIdx: common.Idx(toIdxInt64), + DepositAmount: big.NewInt(0), + TokenID: common.TokenID(tokenIDERC777), + Amount: amount, } L1UserTxs = append(L1UserTxs, l1Tx) - _, err = rollupClientAux.RollupL1UserTxERC20Permit(l1Tx.FromBJJ, fromIdxInt64, l1Tx.LoadAmount, l1Tx.Amount, tokenIDERC777, toIdxInt64, deadline) + _, err = rollupClientAux.RollupL1UserTxERC20Permit(l1Tx.FromBJJ, fromIdxInt64, l1Tx.DepositAmount, l1Tx.Amount, tokenIDERC777, toIdxInt64, deadline) require.NoError(t, err) currentBlockNum, err := rollupClient.client.EthLastBlock()@@ -711,7 +711,7 @@ require.NoError(t, err)
rollupEvents, _, err := rollupClient.RollupEventsByBlock(currentBlockNum) require.NoError(t, err) assert.Equal(t, l1Tx.ToIdx, rollupEvents.L1UserTx[0].L1UserTx.ToIdx) - assert.Equal(t, l1Tx.LoadAmount, rollupEvents.L1UserTx[0].L1UserTx.LoadAmount) + assert.Equal(t, l1Tx.DepositAmount, rollupEvents.L1UserTx[0].L1UserTx.DepositAmount) assert.Equal(t, l1Tx.TokenID, rollupEvents.L1UserTx[0].L1UserTx.TokenID) assert.Equal(t, l1Tx.Amount, rollupEvents.L1UserTx[0].L1UserTx.Amount) assert.Equal(t, rollupClientAux.client.account.Address, rollupEvents.L1UserTx[0].L1UserTx.FromEthAddr)@@ -725,15 +725,15 @@ toIdxInt64 := int64(1)
tokenIDUint32 := uint32(0) amount, _ := new(big.Int).SetString("10000000000000000000", 10) l1Tx := common.L1Tx{ - FromIdx: common.Idx(fromIdxInt64), - ToIdx: common.Idx(toIdxInt64), - LoadAmount: big.NewInt(0), - TokenID: common.TokenID(tokenIDUint32), - Amount: amount, + FromIdx: common.Idx(fromIdxInt64), + ToIdx: common.Idx(toIdxInt64), + DepositAmount: big.NewInt(0), + TokenID: common.TokenID(tokenIDUint32), + Amount: amount, } L1UserTxs = append(L1UserTxs, l1Tx) - _, err = rollupClientAux.RollupL1UserTxERC20ETH(l1Tx.FromBJJ, fromIdxInt64, l1Tx.LoadAmount, l1Tx.Amount, tokenIDUint32, toIdxInt64) + _, err = rollupClientAux.RollupL1UserTxERC20ETH(l1Tx.FromBJJ, fromIdxInt64, l1Tx.DepositAmount, l1Tx.Amount, tokenIDUint32, toIdxInt64) require.NoError(t, err) currentBlockNum, err := rollupClient.client.EthLastBlock()@@ -741,7 +741,7 @@ require.NoError(t, err)
rollupEvents, _, err := rollupClient.RollupEventsByBlock(currentBlockNum) require.NoError(t, err) assert.Equal(t, l1Tx.ToIdx, rollupEvents.L1UserTx[0].L1UserTx.ToIdx) - assert.Equal(t, l1Tx.LoadAmount, rollupEvents.L1UserTx[0].L1UserTx.LoadAmount) + assert.Equal(t, l1Tx.DepositAmount, rollupEvents.L1UserTx[0].L1UserTx.DepositAmount) assert.Equal(t, l1Tx.TokenID, rollupEvents.L1UserTx[0].L1UserTx.TokenID) assert.Equal(t, l1Tx.Amount, rollupEvents.L1UserTx[0].L1UserTx.Amount) assert.Equal(t, rollupClientAux.client.account.Address, rollupEvents.L1UserTx[0].L1UserTx.FromEthAddr)@@ -754,15 +754,15 @@ fromIdxInt64 := int64(257)
toIdxInt64 := int64(1) amount, _ := new(big.Int).SetString("20000000000000000000", 10) l1Tx := common.L1Tx{ - FromIdx: common.Idx(fromIdxInt64), - ToIdx: common.Idx(toIdxInt64), - LoadAmount: big.NewInt(0), - TokenID: common.TokenID(tokenHEZID), - Amount: amount, + FromIdx: common.Idx(fromIdxInt64), + ToIdx: common.Idx(toIdxInt64), + DepositAmount: big.NewInt(0), + TokenID: common.TokenID(tokenHEZID), + Amount: amount, } L1UserTxs = append(L1UserTxs, l1Tx) - _, err = rollupClientAux2.RollupL1UserTxERC20ETH(l1Tx.FromBJJ, fromIdxInt64, l1Tx.LoadAmount, l1Tx.Amount, tokenHEZID, toIdxInt64) + _, err = rollupClientAux2.RollupL1UserTxERC20ETH(l1Tx.FromBJJ, fromIdxInt64, l1Tx.DepositAmount, l1Tx.Amount, tokenHEZID, toIdxInt64) require.NoError(t, err) currentBlockNum, err := rollupClient.client.EthLastBlock()@@ -770,7 +770,7 @@ require.NoError(t, err)
rollupEvents, _, err := rollupClient.RollupEventsByBlock(currentBlockNum) require.NoError(t, err) assert.Equal(t, l1Tx.ToIdx, rollupEvents.L1UserTx[0].L1UserTx.ToIdx) - assert.Equal(t, l1Tx.LoadAmount, rollupEvents.L1UserTx[0].L1UserTx.LoadAmount) + assert.Equal(t, l1Tx.DepositAmount, rollupEvents.L1UserTx[0].L1UserTx.DepositAmount) assert.Equal(t, l1Tx.TokenID, rollupEvents.L1UserTx[0].L1UserTx.TokenID) assert.Equal(t, l1Tx.Amount, rollupEvents.L1UserTx[0].L1UserTx.Amount) assert.Equal(t, rollupClientAux2.client.account.Address, rollupEvents.L1UserTx[0].L1UserTx.FromEthAddr)@@ -785,15 +785,15 @@ fromIdx := new(common.Idx)
*fromIdx = 0 amount, _ := new(big.Int).SetString("30000000000000000000", 10) l1Tx := common.L1Tx{ - FromIdx: common.Idx(fromIdxInt64), - ToIdx: common.Idx(toIdxInt64), - LoadAmount: big.NewInt(0), - TokenID: common.TokenID(tokenIDERC777), - Amount: amount, + FromIdx: common.Idx(fromIdxInt64), + ToIdx: common.Idx(toIdxInt64), + DepositAmount: big.NewInt(0), + TokenID: common.TokenID(tokenIDERC777), + Amount: amount, } L1UserTxs = append(L1UserTxs, l1Tx) - _, err = rollupClientAux.RollupL1UserTxERC20Permit(l1Tx.FromBJJ, fromIdxInt64, l1Tx.LoadAmount, l1Tx.Amount, tokenIDERC777, toIdxInt64, deadline) + _, err = rollupClientAux.RollupL1UserTxERC20Permit(l1Tx.FromBJJ, fromIdxInt64, l1Tx.DepositAmount, l1Tx.Amount, tokenIDERC777, toIdxInt64, deadline) require.NoError(t, err) currentBlockNum, err := rollupClient.client.EthLastBlock()@@ -801,7 +801,7 @@ require.NoError(t, err)
rollupEvents, _, err := rollupClient.RollupEventsByBlock(currentBlockNum) require.NoError(t, err) assert.Equal(t, l1Tx.ToIdx, rollupEvents.L1UserTx[0].L1UserTx.ToIdx) - assert.Equal(t, l1Tx.LoadAmount, rollupEvents.L1UserTx[0].L1UserTx.LoadAmount) + assert.Equal(t, l1Tx.DepositAmount, rollupEvents.L1UserTx[0].L1UserTx.DepositAmount) assert.Equal(t, l1Tx.TokenID, rollupEvents.L1UserTx[0].L1UserTx.TokenID) assert.Equal(t, l1Tx.Amount, rollupEvents.L1UserTx[0].L1UserTx.Amount) assert.Equal(t, rollupClientAux.client.account.Address, rollupEvents.L1UserTx[0].L1UserTx.FromEthAddr)
@@ -81,13 +81,13 @@ assert.Equal(t, len(block.Rollup.L1UserTxs), len(syncBlock.Rollup.L1UserTxs))
dbL1UserTxs, err := s.historyDB.GetAllL1UserTxs() require.Nil(t, err) // Ignore BatchNum in syncBlock.L1UserTxs because this value is set by - // the HistoryDB. Also ignore EffectiveAmount & EffectiveLoadAmount + // the HistoryDB. Also ignore EffectiveAmount & EffectiveDepositAmount // because this value is set by StateDB.ProcessTxs. for i := range syncBlock.Rollup.L1UserTxs { syncBlock.Rollup.L1UserTxs[i].BatchNum = block.Rollup.L1UserTxs[i].BatchNum syncBlock.Rollup.L1UserTxs[i].EffectiveAmount = block.Rollup.L1UserTxs[i].EffectiveAmount - syncBlock.Rollup.L1UserTxs[i].EffectiveLoadAmount = - block.Rollup.L1UserTxs[i].EffectiveLoadAmount + syncBlock.Rollup.L1UserTxs[i].EffectiveDepositAmount = + block.Rollup.L1UserTxs[i].EffectiveDepositAmount } assert.Equal(t, block.Rollup.L1UserTxs, syncBlock.Rollup.L1UserTxs) for _, tx := range block.Rollup.L1UserTxs {@@ -102,7 +102,7 @@ break
} } tx.EffectiveAmount = tx.Amount - tx.EffectiveLoadAmount = tx.LoadAmount + tx.EffectiveDepositAmount = tx.DepositAmount assert.Equal(t, &tx, dbTx) //nolint:gosec }@@ -255,7 +255,7 @@ require.Nil(t, err)
} for _, tx := range block.Rollup.L1UserTxs { client.CtlSetAddr(tx.FromEthAddr) - _, err := client.RollupL1UserTxERC20ETH(tx.FromBJJ, int64(tx.FromIdx), tx.LoadAmount, tx.Amount, + _, err := client.RollupL1UserTxERC20ETH(tx.FromBJJ, int64(tx.FromIdx), tx.DepositAmount, tx.Amount, uint32(tx.TokenID), int64(tx.ToIdx)) require.Nil(t, err) }
@@ -716,7 +716,7 @@ // })
// } // RollupL1UserTxERC20Permit is the interface to call the smart contract function -func (c *Client) RollupL1UserTxERC20Permit(fromBJJ *babyjub.PublicKey, fromIdx int64, loadAmount *big.Int, amount *big.Int, tokenID uint32, toIdx int64, deadline *big.Int) (tx *types.Transaction, err error) { +func (c *Client) RollupL1UserTxERC20Permit(fromBJJ *babyjub.PublicKey, fromIdx int64, depositAmount *big.Int, amount *big.Int, tokenID uint32, toIdx int64, deadline *big.Int) (tx *types.Transaction, err error) { log.Error("TODO") return nil, tracerr.Wrap(errTODO) }@@ -725,7 +725,7 @@ // RollupL1UserTxERC20ETH sends an L1UserTx to the Rollup.
func (c *Client) RollupL1UserTxERC20ETH( fromBJJ *babyjub.PublicKey, fromIdx int64, - loadAmount *big.Int, + depositAmount *big.Int, amount *big.Int, tokenID uint32, toIdx int64,@@ -739,7 +739,7 @@ _, err = common.NewFloat16(amount)
if err != nil { return nil, tracerr.Wrap(err) } - _, err = common.NewFloat16(loadAmount) + _, err = common.NewFloat16(depositAmount) if err != nil { return nil, tracerr.Wrap(err) }@@ -764,7 +764,7 @@ FromIdx: common.Idx(fromIdx),
FromEthAddr: *c.addr, FromBJJ: fromBJJ, Amount: amount, - LoadAmount: loadAmount, + DepositAmount: depositAmount, TokenID: common.TokenID(tokenID), ToIdx: common.Idx(toIdx), ToForgeL1TxsNum: &toForgeL1TxsNum,@@ -783,7 +783,7 @@ return r.addTransaction(c.newTransaction("l1UserTxERC20ETH", l1Tx)), nil
} // RollupL1UserTxERC777 is the interface to call the smart contract function -// func (c *Client) RollupL1UserTxERC777(fromBJJ *babyjub.PublicKey, fromIdx int64, loadAmount *big.Int, amount *big.Int, tokenID uint32, toIdx int64) (*types.Transaction, error) { +// func (c *Client) RollupL1UserTxERC777(fromBJJ *babyjub.PublicKey, fromIdx int64, depositAmount *big.Int, amount *big.Int, tokenID uint32, toIdx int64) (*types.Transaction, error) { // log.Error("TODO") // return nil, errTODO // }
@@ -156,14 +156,14 @@ var keys [N]*keys
for i := 0; i < N; i++ { keys[i] = genKeys(int64(i)) tx := common.L1Tx{ - FromIdx: 0, - FromEthAddr: keys[i].Addr, - FromBJJ: keys[i].BJJPublicKey, - TokenID: common.TokenID(0), - Amount: big.NewInt(0), - LoadAmount: big.NewInt(10 + int64(i)), + FromIdx: 0, + FromEthAddr: keys[i].Addr, + FromBJJ: keys[i].BJJPublicKey, + TokenID: common.TokenID(0), + Amount: big.NewInt(0), + DepositAmount: big.NewInt(10 + int64(i)), } - _, err := c.RollupL1UserTxERC20ETH(tx.FromBJJ, int64(tx.FromIdx), tx.LoadAmount, + _, err := c.RollupL1UserTxERC20ETH(tx.FromBJJ, int64(tx.FromIdx), tx.DepositAmount, tx.Amount, uint32(tx.TokenID), int64(tx.ToIdx)) require.Nil(t, err) }
@@ -157,12 +157,12 @@ for i := fromIdx; i < fromIdx+totalTxs; i++ {
token := tokens[i%len(tokens)] amount := big.NewInt(int64(i + 1)) tx := common.L1Tx{ - Position: i - fromIdx, - UserOrigin: i%2 == 0, - TokenID: token.TokenID, - Amount: amount, - LoadAmount: amount, - EthBlockNum: blocks[i%len(blocks)].Num, + Position: i - fromIdx, + UserOrigin: i%2 == 0, + TokenID: token.TokenID, + Amount: amount, + DepositAmount: amount, + EthBlockNum: blocks[i%len(blocks)].Num, } if tx.UserOrigin { n := nextTxsNum
@@ -63,15 +63,15 @@ )
// Instruction is the data structure that represents one line of code type Instruction struct { - LineNum int - Literal string - From string - To string - Amount *big.Int - LoadAmount *big.Int - Fee uint8 - TokenID common.TokenID - Typ common.TxType // D: Deposit, T: Transfer, E: ForceExit + LineNum int + Literal string + From string + To string + Amount *big.Int + DepositAmount *big.Int + Fee uint8 + TokenID common.TokenID + Typ common.TxType // D: Deposit, T: Transfer, E: ForceExit } // parsedSet contains the full Set of Instructions representing a full code@@ -94,7 +94,7 @@
if i.Typ == common.TxTypeDeposit || i.Typ == common.TxTypeDepositTransfer || i.Typ == common.TxTypeCreateAccountDepositTransfer { - fmt.Fprintf(buf, "LoadAmount: %d, ", i.LoadAmount) + fmt.Fprintf(buf, "DepositAmount: %d, ", i.DepositAmount) } if i.Typ != common.TxTypeDeposit { fmt.Fprintf(buf, "Amount: %d, ", i.Amount)@@ -123,7 +123,7 @@ fmt.Fprintf(buf, ":")
if i.Typ == common.TxTypeDeposit || i.Typ == common.TxTypeDepositTransfer || i.Typ == common.TxTypeCreateAccountDepositTransfer { - fmt.Fprintf(buf, "%d", i.LoadAmount) + fmt.Fprintf(buf, "%d", i.DepositAmount) } if i.Typ != common.TxTypeDeposit { fmt.Fprintf(buf, "%d", i.Amount)@@ -439,13 +439,13 @@ c.Typ == common.TxTypeCreateAccountDepositTransfer {
// deposit case _, lit = p.scanIgnoreWhitespace() c.Literal += lit - loadAmount, ok := new(big.Int).SetString(lit, 10) + depositAmount, ok := new(big.Int).SetString(lit, 10) if !ok { line, _ := p.s.r.ReadString('\n') c.Literal += line - return c, tracerr.Wrap(fmt.Errorf("Can not parse number for LoadAmount")) + return c, tracerr.Wrap(fmt.Errorf("Can not parse number for DepositAmount")) } - c.LoadAmount = loadAmount + c.DepositAmount = depositAmount if err := p.expectChar(c, ","); err != nil { return c, tracerr.Wrap(err) }@@ -460,7 +460,7 @@ return c, tracerr.Wrap(fmt.Errorf("Can not parse number for Amount: %s", lit))
} if c.Typ == common.TxTypeDeposit || c.Typ == common.TxTypeCreateAccountDeposit { - c.LoadAmount = amount + c.DepositAmount = amount } else { c.Amount = amount }
@@ -72,7 +72,7 @@
assert.Equal(t, TxTypeCreateAccountDepositCoordinator, instructions.instructions[7].Typ) assert.Equal(t, TypeNewBatch, instructions.instructions[11].Typ) assert.Equal(t, "Deposit(1)User0:20", instructions.instructions[16].raw()) - assert.Equal(t, "Type: DepositTransfer, From: A, To: B, LoadAmount: 15, Amount: 10, Fee: 0, TokenID: 1\n", instructions.instructions[13].String()) + assert.Equal(t, "Type: DepositTransfer, From: A, To: B, DepositAmount: 15, Amount: 10, Fee: 0, TokenID: 1\n", instructions.instructions[13].String()) assert.Equal(t, "Type: Transfer, From: User1, To: User0, Amount: 15, Fee: 1, TokenID: 3\n", instructions.instructions[19].String()) assert.Equal(t, "Transfer(2)A-B:15(1)", instructions.instructions[15].raw()) assert.Equal(t, "Type: Transfer, From: A, To: B, Amount: 15, Fee: 1, TokenID: 2\n", instructions.instructions[15].String())
@@ -199,12 +199,12 @@ log.Error(err)
return nil, tracerr.Wrap(fmt.Errorf("Line %d: %s", inst.LineNum, err.Error())) } tx := common.L1Tx{ - FromEthAddr: tc.Users[inst.From].Addr, - FromBJJ: tc.Users[inst.From].BJJ.Public(), - TokenID: inst.TokenID, - Amount: big.NewInt(0), - LoadAmount: big.NewInt(0), - Type: common.TxTypeCreateAccountDeposit, // as TxTypeCreateAccountDepositCoordinator is not valid oustide Til package + FromEthAddr: tc.Users[inst.From].Addr, + FromBJJ: tc.Users[inst.From].BJJ.Public(), + TokenID: inst.TokenID, + Amount: big.NewInt(0), + DepositAmount: big.NewInt(0), + Type: common.TxTypeCreateAccountDeposit, // as TxTypeCreateAccountDepositCoordinator is not valid oustide Til package } testTx := L1Tx{ lineNum: inst.LineNum,@@ -219,12 +219,12 @@ log.Error(err)
return nil, tracerr.Wrap(fmt.Errorf("Line %d: %s", inst.LineNum, err.Error())) } tx := common.L1Tx{ - FromEthAddr: tc.Users[inst.From].Addr, - FromBJJ: tc.Users[inst.From].BJJ.Public(), - TokenID: inst.TokenID, - Amount: big.NewInt(0), - LoadAmount: inst.LoadAmount, - Type: inst.Typ, + FromEthAddr: tc.Users[inst.From].Addr, + FromBJJ: tc.Users[inst.From].BJJ.Public(), + TokenID: inst.TokenID, + Amount: big.NewInt(0), + DepositAmount: inst.DepositAmount, + Type: inst.Typ, } if inst.Typ == common.TxTypeCreateAccountDepositTransfer { tx.Amount = inst.Amount@@ -248,10 +248,10 @@ log.Error(err)
return nil, tracerr.Wrap(fmt.Errorf("Line %d: %s", inst.LineNum, err.Error())) } tx := common.L1Tx{ - TokenID: inst.TokenID, - Amount: big.NewInt(0), - LoadAmount: inst.LoadAmount, - Type: inst.Typ, + TokenID: inst.TokenID, + Amount: big.NewInt(0), + DepositAmount: inst.DepositAmount, + Type: inst.Typ, } if inst.Typ == common.TxTypeDepositTransfer { tx.Amount = inst.Amount@@ -291,10 +291,10 @@ log.Error(err)
return nil, tracerr.Wrap(fmt.Errorf("Line %d: %s", inst.LineNum, err.Error())) } tx := common.L1Tx{ - TokenID: inst.TokenID, - Amount: inst.Amount, - LoadAmount: big.NewInt(0), - Type: common.TxTypeForceTransfer, + TokenID: inst.TokenID, + Amount: inst.Amount, + DepositAmount: big.NewInt(0), + Type: common.TxTypeForceTransfer, } testTx := L1Tx{ lineNum: inst.LineNum,@@ -332,11 +332,11 @@ log.Error(err)
return nil, tracerr.Wrap(fmt.Errorf("Line %d: %s", inst.LineNum, err.Error())) } tx := common.L1Tx{ - ToIdx: common.Idx(1), // as is an Exit - TokenID: inst.TokenID, - Amount: inst.Amount, - LoadAmount: big.NewInt(0), - Type: common.TxTypeForceExit, + ToIdx: common.Idx(1), // as is an Exit + TokenID: inst.TokenID, + Amount: inst.Amount, + DepositAmount: big.NewInt(0), + Type: common.TxTypeForceExit, } testTx := L1Tx{ lineNum: inst.LineNum,@@ -747,7 +747,7 @@ }
// FillBlocksForgedL1UserTxs fills the L1UserTxs of a batch with the L1UserTxs // that are forged in that batch. It always sets `EffectiveAmount` = `Amount` -// and `EffectiveLoadAmount` = `LoadAmount`. +// and `EffectiveDepositAmount` = `DepositAmount`. func (tc *Context) FillBlocksForgedL1UserTxs(blocks []common.BlockData) error { for i := range blocks { block := &blocks[i]@@ -761,7 +761,7 @@ for k := range queue {
tx := &batch.L1UserTxs[k] *tx = queue[k].L1Tx tx.EffectiveAmount = tx.Amount - tx.EffectiveLoadAmount = tx.LoadAmount + tx.EffectiveDepositAmount = tx.DepositAmount tx.BatchNum = &batchNum _tx, err := common.NewL1Tx(tx) if err != nil {@@ -786,7 +786,7 @@ // - blocks[].Rollup.Batch.L1CoordinatorTxs[].BatchNum
// - blocks[].Rollup.Batch.L1CoordinatorTxs[].EthBlockNum // - blocks[].Rollup.Batch.L1CoordinatorTxs[].Position // - blocks[].Rollup.Batch.L1CoordinatorTxs[].EffectiveAmount -// - blocks[].Rollup.Batch.L1CoordinatorTxs[].EffectiveLoadAmount +// - blocks[].Rollup.Batch.L1CoordinatorTxs[].EffectiveDepositAmount // - blocks[].Rollup.Batch.L2Txs[].TxID // - blocks[].Rollup.Batch.L2Txs[].Position // - blocks[].Rollup.Batch.L2Txs[].Nonce@@ -869,7 +869,7 @@ tx := &batch.L1CoordinatorTxs[k]
tx.Position = position position++ tx.EffectiveAmount = big.NewInt(0) - tx.EffectiveLoadAmount = big.NewInt(0) + tx.EffectiveDepositAmount = big.NewInt(0) nTx, err := common.NewL1Tx(tx) if err != nil { return tracerr.Wrap(err)
@@ -141,7 +141,7 @@ // #19: Transfer(1) A-B: 1 (1)
tc.checkL2TxParams(t, blocks[1].Rollup.Batches[0].L2Txs[1], common.TxTypeTransfer, 1, "A", "B", big.NewInt(1), common.BatchNum(6)) } -func (tc *Context) checkL1TxParams(t *testing.T, tx common.L1Tx, typ common.TxType, tokenID common.TokenID, from, to string, loadAmount, amount *big.Int) { +func (tc *Context) checkL1TxParams(t *testing.T, tx common.L1Tx, typ common.TxType, tokenID common.TokenID, from, to string, depositAmount, amount *big.Int) { assert.Equal(t, typ, tx.Type) if tx.FromIdx != common.Idx(0) { assert.Equal(t, tc.Users[from].Accounts[tokenID].Idx, tx.FromIdx)@@ -151,8 +151,8 @@ assert.Equal(t, tc.Users[from].BJJ.Public(), tx.FromBJJ)
if tx.ToIdx != common.Idx(0) { assert.Equal(t, tc.Users[to].Accounts[tokenID].Idx, tx.ToIdx) } - if loadAmount != nil { - assert.Equal(t, loadAmount, tx.LoadAmount) + if depositAmount != nil { + assert.Equal(t, depositAmount, tx.DepositAmount) } if amount != nil { assert.Equal(t, amount, tx.Amount)@@ -432,14 +432,14 @@ Typ: TypeAddToken,
TokenID: 1, }) i++ - la := big.NewInt(10) + da := big.NewInt(10) setInst = append(setInst, Instruction{ LineNum: i, // Literal: "CreateAccountDeposit(1) A: 10", - Typ: common.TxTypeCreateAccountDeposit, - From: "A", - TokenID: 1, - LoadAmount: la, + Typ: common.TxTypeCreateAccountDeposit, + From: "A", + TokenID: 1, + DepositAmount: da, }) i++ setInst = append(setInst, Instruction{
@@ -160,13 +160,13 @@ validTxs = append(validTxs, l2TxsRaw[i])
} // create L1CoordinatorTx for the accountCreation l1CoordinatorTx := common.L1Tx{ - Position: positionL1, - UserOrigin: false, - FromEthAddr: accAuth.EthAddr, - FromBJJ: accAuth.BJJ, - TokenID: l2TxsRaw[i].TokenID, - LoadAmount: big.NewInt(0), - Type: common.TxTypeCreateAccountDeposit, + Position: positionL1, + UserOrigin: false, + FromEthAddr: accAuth.EthAddr, + FromBJJ: accAuth.BJJ, + TokenID: l2TxsRaw[i].TokenID, + DepositAmount: big.NewInt(0), + Type: common.TxTypeCreateAccountDeposit, } positionL1++ l1CoordinatorTxs = append(l1CoordinatorTxs, l1CoordinatorTx)@@ -185,13 +185,13 @@ // coordinator can create a new account without
// L1Authorization, as ToEthAddr==0xff // create L1CoordinatorTx for the accountCreation l1CoordinatorTx := common.L1Tx{ - Position: positionL1, - UserOrigin: false, - FromEthAddr: l2TxsRaw[i].ToEthAddr, - FromBJJ: l2TxsRaw[i].ToBJJ, - TokenID: l2TxsRaw[i].TokenID, - LoadAmount: big.NewInt(0), - Type: common.TxTypeCreateAccountDeposit, + Position: positionL1, + UserOrigin: false, + FromEthAddr: l2TxsRaw[i].ToEthAddr, + FromBJJ: l2TxsRaw[i].ToBJJ, + TokenID: l2TxsRaw[i].TokenID, + DepositAmount: big.NewInt(0), + Type: common.TxTypeCreateAccountDeposit, } positionL1++ l1CoordinatorTxs = append(l1CoordinatorTxs, l1CoordinatorTx)