From ebeac8747061dc0c0244238bd7a9468899e12e54 Mon Sep 17 00:00:00 2001 From: kaiden-araki Date: Tue, 12 Nov 2024 19:53:48 +1100 Subject: [PATCH] fix/fix til and txprocessor for sync test scenario (#56) --- sequencer/common/l2tx.go | 3 ++- sequencer/database/migrations/0001.sql | 2 +- sequencer/test/til/lang.go | 3 +-- sequencer/test/til/txs.go | 8 ++++---- sequencer/txprocessor/txprocessor.go | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/sequencer/common/l2tx.go b/sequencer/common/l2tx.go index 6ccc5d6..560074d 100644 --- a/sequencer/common/l2tx.go +++ b/sequencer/common/l2tx.go @@ -17,7 +17,8 @@ type L2Tx struct { ToIdx AccountIdx `meddler:"to_idx"` Nonce Nonce `meddler:"nonce"` Type TxType `meddler:"type"` - Amount *big.Int `meddler:"amount,bigint"` + // TODO: Amount should be remoged from L2Tx struct + Amount *big.Int `meddler:"amount,bigint"` // EthBlockNum in which this L2Tx was added to the queue EthBlockNum int64 `meddler:"eth_block_num"` } diff --git a/sequencer/database/migrations/0001.sql b/sequencer/database/migrations/0001.sql index 9bfcb5b..aa4d786 100644 --- a/sequencer/database/migrations/0001.sql +++ b/sequencer/database/migrations/0001.sql @@ -177,7 +177,7 @@ CREATE TABLE tx ( amount DECIMAL(78,0) NOT NULL, amount_success BOOLEAN NOT NULL DEFAULT true, amount_f NUMERIC NOT NULL, - token_id INT NOT NULL REFERENCES token (token_id), + -- token_id INT NOT NULL REFERENCES token (token_id), amount_usd NUMERIC, -- Value of the amount in USD at the moment the tx was inserted in the DB batch_num BIGINT REFERENCES batch (batch_num) ON DELETE SET NULL, -- Can be NULL in the case of L1 txs that are on the queue but not forged yet. eth_block_num BIGINT NOT NULL REFERENCES block (eth_block_num) ON DELETE CASCADE, diff --git a/sequencer/test/til/lang.go b/sequencer/test/til/lang.go index a37aecd..e2b69c3 100644 --- a/sequencer/test/til/lang.go +++ b/sequencer/test/til/lang.go @@ -6,7 +6,6 @@ import ( "fmt" "io" "math/big" - "sort" "strconv" "tokamak-sybil-resistance/common" "tokamak-sybil-resistance/log" @@ -486,6 +485,6 @@ func (p *parser) parse() (*parsedSet, error) { for u := range users { ps.users = append(ps.users, u) } - sort.Strings(ps.users) + // sort.Strings(ps.users) return ps, nil } diff --git a/sequencer/test/til/txs.go b/sequencer/test/til/txs.go index 3381f0c..b12a1e0 100644 --- a/sequencer/test/til/txs.go +++ b/sequencer/test/til/txs.go @@ -233,7 +233,7 @@ func (tc *Context) generateBlocks() ([]common.BlockData, error) { } case common.TxTypeCreateVouch: tx := common.L2Tx{ - // Amount: inst.Amount, + Amount: big.NewInt(0), // Fee: common.FeeSelector(inst.Fee), Type: common.TxTypeCreateVouch, EthBlockNum: tc.blockNum, @@ -249,7 +249,7 @@ func (tc *Context) generateBlocks() ([]common.BlockData, error) { tc.currBatchTest.l2Txs = append(tc.currBatchTest.l2Txs, testTx) case common.TxTypeDeleteVouch: tx := common.L2Tx{ - // Amount: inst.Amount, + Amount: big.NewInt(0), // Fee: common.FeeSelector(inst.Fee), Type: common.TxTypeDeleteVouch, EthBlockNum: tc.blockNum, @@ -802,7 +802,7 @@ func (tc *Context) FillBlocksExtra(blocks []common.BlockData, cfg *ConfigExtra) BJJ: user.BJJ.Public().Compress(), EthAddr: user.Addr, Nonce: 0, - Balance: big.NewInt(100), + Balance: big.NewInt(0), }) if !tx.UserOrigin { tx.EffectiveFromIdx = common.AccountIdx(tc.extra.idx) @@ -879,7 +879,7 @@ func (tc *Context) FillBlocksExtra(blocks []common.BlockData, cfg *ConfigExtra) batch.ExitTree = append(batch.ExitTree, common.ExitInfo{ BatchNum: batch.Batch.BatchNum, AccountIdx: tx.FromIdx, - // Balance: tx.Amount, + Balance: tx.Amount, }) } // fee, err := common.CalcFeeAmount(tx.Amount, tx.Fee) diff --git a/sequencer/txprocessor/txprocessor.go b/sequencer/txprocessor/txprocessor.go index be4e7a2..ee6f221 100644 --- a/sequencer/txprocessor/txprocessor.go +++ b/sequencer/txprocessor/txprocessor.go @@ -1046,7 +1046,7 @@ func (txProcessor *TxProcessor) applyTransfer(coordIdxsMap map[common.TokenID]co } // add amount-feeAmount to the receiver - accReceiver.Balance = new(big.Int).Add(accReceiver.Balance, tx.Amount) + // accReceiver.Balance = new(big.Int).Add(accReceiver.Balance, tx.Amount) // update receiver account in localStateDB pReceiver, err := txProcessor.updateAccount(auxToIdx, accReceiver)