Skip to content

Commit

Permalink
fix/fix til and txprocessor for sync test scenario (#56)
Browse files Browse the repository at this point in the history
  • Loading branch information
kaiden-araki authored Nov 12, 2024
1 parent 549d31f commit ebeac87
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
3 changes: 2 additions & 1 deletion sequencer/common/l2tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}
Expand Down
2 changes: 1 addition & 1 deletion sequencer/database/migrations/0001.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 1 addition & 2 deletions sequencer/test/til/lang.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"fmt"
"io"
"math/big"
"sort"
"strconv"
"tokamak-sybil-resistance/common"
"tokamak-sybil-resistance/log"
Expand Down Expand Up @@ -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
}
8 changes: 4 additions & 4 deletions sequencer/test/til/txs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion sequencer/txprocessor/txprocessor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit ebeac87

Please sign in to comment.