From 445f26ec9f908f0ced10565121c3556ff1862515 Mon Sep 17 00:00:00 2001 From: Arnau B Date: Fri, 4 Dec 2020 13:20:18 +0100 Subject: [PATCH] Rename load amount to deposit amount --- api/config.go | 4 +- api/swagger.yml | 28 +-- api/txshistory_test.go | 24 +-- common/ethrollup.go | 6 +- common/l1tx.go | 34 ++-- common/l1tx_test.go | 64 +++---- common/pooll2tx.go | 4 +- common/tx.go | 18 +- common/zk.go | 6 +- db/historydb/historydb.go | 64 +++---- db/historydb/historydb_test.go | 34 ++-- db/historydb/views.go | 24 +-- db/migrations/0001.sql | 24 +-- db/statedb/txprocessors.go | 48 ++--- db/statedb/txprocessors_test.go | 170 +++++++++--------- eth/rollup.go | 20 +-- eth/rollup_test.go | 286 +++++++++++++++--------------- synchronizer/synchronizer_test.go | 10 +- test/ethclient.go | 10 +- test/ethclient_test.go | 14 +- test/historydb.go | 12 +- test/til/lang.go | 30 ++-- test/til/lang_test.go | 2 +- test/til/txs.go | 58 +++--- test/til/txs_test.go | 16 +- txselector/txselector.go | 28 +-- 26 files changed, 519 insertions(+), 519 deletions(-) diff --git a/api/config.go b/api/config.go index d7b60b1..9418c24 100644 --- a/api/config.go +++ b/api/config.go @@ -13,7 +13,7 @@ type rollupConstants struct { 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 @@ func newRollupConstants(publicConstants common.RollupConstants) *rollupConstants MaxFeeIdxCoordinator: common.RollupConstMaxFeeIdxCoordinator, ReservedIdx: common.RollupConstReservedIDx, ExitIdx: common.RollupConstExitIDx, - LimitLoadAmount: common.RollupConstLimitLoadAmount, + LimitDepositAmount: common.RollupConstLimitDepositAmount, LimitL2TransferAmount: common.RollupConstLimitL2TransferAmount, LimitTokens: common.RollupConstLimitTokens, L1CoordinatorTotalBytes: common.RollupConstL1CoordinatorTotalBytes, diff --git a/api/swagger.yml b/api/swagger.yml index d71394e..4e5ba86 100644 --- a/api/swagger.yml +++ b/api/swagger.yml @@ -1745,12 +1745,12 @@ components: 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 @@ components: required: - toForgeL1TransactionsNum - userOrigin - - loadAmount - - historicLoadAmountUSD + - depositAmount + - historicDepositAmountUSD - ethereumBlockNum additionalProperties: false L2Info: @@ -1790,8 +1790,8 @@ components: example: L1Info: ethereumBlockNum: 1 - historicLoadAmountUSD: 232.47 - loadAmount: '261' + historicDepositAmountUSD: 232.47 + depositAmount: '261' toForgeL1TransactionsNum: 10 userOrigin: true L1orL2: L1 @@ -1854,8 +1854,8 @@ components: transactions: - L1Info: ethereumBlockNum: 3 - historicLoadAmountUSD: - loadAmount: '0' + historicDepositAmountUSD: + depositAmount: '0' toForgeL1TransactionsNum: 7 userOrigin: true L1orL2: L1 @@ -1946,8 +1946,8 @@ components: 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 @@ components: example: accounts: - accountIndex: hez:ETH:259 - balance: '2590000000' + balance: '2590000000000000000' bjj: hez:W6x4TZOAZ9mAqdOb3Xm_hKDLspaXfEfMMN4tXOkinS-W hezEthereumAddress: hez:0x7E5F4552091A69125d5DfCb7b8C2659029395Bdf itemId: 4 @@ -2954,7 +2954,7 @@ components: 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 @@ components: 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 @@ components: - publicConstants - reservedIdx - exitIdx - - limitLoadAmount + - limitDepositAmount - limitL2TransferAmount - limitTokens - l1CoordinatorTotalBytes diff --git a/api/txshistory_test.go b/api/txshistory_test.go index d67922c..f7772db 100644 --- a/api/txshistory_test.go +++ b/api/txshistory_test.go @@ -18,11 +18,11 @@ import ( ) 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 @@ func genTestTxs( 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 @@ func genTestTxs( 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 @@ func assertTxs(t *testing.T, expected, actual []testTx) { 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]) } diff --git a/common/ethrollup.go b/common/ethrollup.go index d827d17..0e64585 100644 --- a/common/ethrollup.go +++ b/common/ethrollup.go @@ -66,7 +66,7 @@ const ( // 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 @@ const ( ) 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) diff --git a/common/l1tx.go b/common/l1tx.go index a529eaf..b51e882 100644 --- a/common/l1tx.go +++ b/common/l1tx.go @@ -32,7 +32,7 @@ type L1Tx struct { 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 @@ type L1Tx struct { 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 @@ func NewL1Tx(l1Tx *L1Tx) (*L1Tx, error) { } 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 @@ func (tx L1Tx) Tx() Tx { 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 @@ func (tx *L1Tx) BytesGeneric() ([]byte, error) { 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 @@ func L1UserTxFromBytes(b []byte) (*L1Tx, error) { 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 @@ func L1CoordinatorTxFromBytes(b []byte, chainID *big.Int, hermezAddress ethCommo 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 diff --git a/common/l1tx_test.go b/common/l1tx_test.go index 359282f..7236f09 100644 --- a/common/l1tx_test.go +++ b/common/l1tx_test.go @@ -24,7 +24,7 @@ func TestNewL1UserTx(t *testing.T) { 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 TestNewL1UserTx(t *testing.T) { 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 @@ func TestL1userTxByteParsers(t *testing.T) { 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 @@ func TestL1TxByteParsersCompatibility(t *testing.T) { 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 @@ func TestL1CoordinatorTxByteParsers(t *testing.T) { 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) diff --git a/common/pooll2tx.go b/common/pooll2tx.go index 5fc9203..d52c85e 100644 --- a/common/pooll2tx.go +++ b/common/pooll2tx.go @@ -33,8 +33,8 @@ type PoolL2Tx struct { 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"` diff --git a/common/tx.go b/common/tx.go index ca44f4a..5b28412 100644 --- a/common/tx.go +++ b/common/tx.go @@ -140,13 +140,13 @@ type Tx struct { 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 @@ func (tx *Tx) String() string { 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 @@ func (tx *Tx) L1Tx() (*L1Tx, error) { ToIdx: tx.ToIdx, TokenID: tx.TokenID, Amount: tx.Amount, - LoadAmount: tx.LoadAmount, + DepositAmount: tx.DepositAmount, EthBlockNum: tx.EthBlockNum, Type: tx.Type, BatchNum: tx.BatchNum, diff --git a/common/zk.go b/common/zk.go index 49cb239..51510d2 100644 --- a/common/zk.go +++ b/common/zk.go @@ -106,8 +106,8 @@ type ZKInputs struct { // // 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 @@ func NewZKInputs(nTx, maxL1Tx, maxTx, maxFeeIdxs, nLevels uint32, currentNumBatc 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++ { diff --git a/db/historydb/historydb.go b/db/historydb/historydb.go index 8d072cf..0989af0 100644 --- a/db/historydb/historydb.go +++ b/db/historydb/historydb.go @@ -767,23 +767,23 @@ func (hdb *HistoryDB) GetAllAccounts() ([]common.Account, error) { 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 @@ func (hdb *HistoryDB) addL1Txs(d meddler.DB, l1txs []common.L1Tx) error { 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 @@ func (hdb *HistoryDB) addTxs(d meddler.DB, txs []txWrite) error { 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 @@ func (hdb *HistoryDB) GetHistoryTx(txID common.TxID) (*TxAPI, error) { 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 @@ func (hdb *HistoryDB) GetHistoryTxs( 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 @@ func (hdb *HistoryDB) GetAllL1UserTxs() ([]common.L1Tx, error) { `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 @@ func (hdb *HistoryDB) GetAllL1CoordinatorTxs() ([]common.L1Tx, error) { `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 @@ func (hdb *HistoryDB) GetUnforgedL1UserTxs(toForgeL1TxsNum int64) ([]common.L1Tx `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 @@ func (hdb *HistoryDB) SetInitialSCVars(rollup *common.RollupVariables, 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 @@ func (hdb *HistoryDB) setL1UserTxEffectiveAmounts(d sqlx.Ext, txs []common.L1Tx) } 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 @@ func (hdb *HistoryDB) AddBlockSCData(blockData *common.BlockData) (err error) { 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 { diff --git a/db/historydb/historydb_test.go b/db/historydb/historydb_test.go index a216c19..baa9224 100644 --- a/db/historydb/historydb_test.go +++ b/db/historydb/historydb_test.go @@ -517,16 +517,16 @@ func TestTxs(t *testing.T) { 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 @@ func TestSetL1UserTxEffectiveAmounts(t *testing.T) { 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 @@ func TestSetL1UserTxEffectiveAmounts(t *testing.T) { 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) } } diff --git a/db/historydb/views.go b/db/historydb/views.go index 5a3887c..cee907f 100644 --- a/db/historydb/views.go +++ b/db/historydb/views.go @@ -32,10 +32,10 @@ type TxAPI struct { 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 @@ func (tx TxAPI) MarshalJSON() ([]byte, error) { 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 @@ type txWrite struct { 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"` diff --git a/db/migrations/0001.sql b/db/migrations/0001.sql index 4ed7180..20fd9f0 100644 --- a/db/migrations/0001.sql +++ b/db/migrations/0001.sql @@ -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 @@ CREATE TABLE tx ( -- 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 @@ BEGIN 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 @@ BEGIN 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; diff --git a/db/statedb/txprocessors.go b/db/statedb/txprocessors.go index d6555c5..693a62b 100644 --- a/db/statedb/txprocessors.go +++ b/db/statedb/txprocessors.go @@ -455,11 +455,11 @@ func (s *StateDB) processL1Tx(exitTree *merkletree.MerkleTree, tx *common.L1Tx) 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 @@ func (s *StateDB) applyCreateAccount(tx *common.L1Tx) error { 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 @@ func (s *StateDB) applyCreateAccount(tx *common.L1Tx) error { // 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 @@ func (s *StateDB) applyCreateAccountDepositTransfer(tx *common.L1Tx) error { 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