arnaucube
arnaucube/hermez-nodePublic Self-hosted repository
Update fees usage in Til
arnaucube root@arnaucube.com
Fri, 23 Oct 2020 18:09:14 +0200
commit

e76cc98e4c0c319a9fb87aaef3ef36f34556ed0a

parent

721e5e8bf0affecff4f80d89a09a0fade89755d0

5 files changed, 37 insertions(+), 28 deletions(-)

jump to
M test/til/README.md → test/til/README.md

@@ -27,8 +27,8 @@ CreateAccountDeposit(1) A: 50

// create the account of TokenID=1 for the user B, deposit of TokenID=1, on the // account of tokenID=1 for the user B, of an amount of 40 units and atomically -// transfer 10 units to account of tokenID=1 for the user A, paying a fee of 2 -CreateAccountDepositTransfer(1) B-A: 40, 10 (2) +// transfer 10 units to account of tokenID=1 for the user A +CreateAccountDepositTransfer(1) B-A: 40, 10 // transaction generated by the Coordinator, create account for user User0 for // the TokenID=2, with a deposit of 0

@@ -40,20 +40,20 @@ Deposit(1) A: 6

// deposit of TokenID=1, on the account of tokenID=1 for the user B, of an // amount of 6 units and atomically transfer 10 units to account of tokenID=1 for -// the user A, paying a fee of 2 -DepositTransfer(1) B-A: 6, 4 (2) +// the user A +DepositTransfer(1) B-A: 6, 4 // transfer of TokenID=1, from the account A to B (for that token), of 6 units, // paying a fee of 3. Transaction will be a L2Tx Transfer(1) A-B: 6 (3) -// exit of TokenID=1, from the account A (for that token), of 5 units. -// Transaction will be a L2Tx -Exit(1) A: 5 +// exit of TokenID=1, from the account A (for that token), of 5 units, paying a +// fee of 1. Transaction will be a L2Tx +Exit(1) A: 5 (1) // force-transfer of TokenID=1, from the account A to B (for that token), of 6 -// units, paying a fee of 3. Transaction will be L1UserTx of ForceTransfer type -ForceTransfer(1) A-B: 6 (3) +// units. Transaction will be L1UserTx of ForceTransfer type +ForceTransfer(1) A-B: 6 // force-exit of TokenID=1, from the account A (for that token), of 5 units. // Transaction will be L1UserTx of ForceExit type

@@ -79,8 +79,9 @@ // transfer of TokenID=1, from the account A to B (for that token), of 6 units,

// paying a fee of 4 PoolTransfer(1) A-B: 6 (4) -// exit of TokenID=1, from the account A (for that token), of 3 units -PoolExit(1) A: 3 +// exit of TokenID=1, from the account A (for that token), of 3 units, paying a +// fee of 1 +PoolExit(1) A: 3 (1) ``` ## Usage
M test/til/lang.go → test/til/lang.go

@@ -332,6 +332,7 @@ if setType == "" {

return c, fmt.Errorf("Set type not defined") } transferring := false + fee := false if setType == setTypeBlockchain { switch lit {

@@ -339,9 +340,11 @@ case "Deposit":

c.typ = common.TxTypeDeposit case "Exit": c.typ = common.TxTypeExit + fee = true case "Transfer": c.typ = common.TxTypeTransfer transferring = true + fee = true case "CreateAccountDeposit": c.typ = common.TxTypeCreateAccountDeposit case "CreateAccountDepositTransfer":

@@ -355,6 +358,7 @@ c.typ = common.TxTypeDepositTransfer

transferring = true case "ForceTransfer": c.typ = common.TxTypeForceTransfer + transferring = true case "ForceExit": c.typ = common.TxTypeForceExit default:

@@ -365,14 +369,18 @@ switch lit {

case "PoolTransfer": c.typ = common.TxTypeTransfer transferring = true + fee = true case "PoolTransferToEthAddr": c.typ = common.TxTypeTransferToEthAddr transferring = true + fee = true case "PoolTransferToBJJ": c.typ = common.TxTypeTransferToBJJ transferring = true + fee = true case "PoolExit": c.typ = common.TxTypeExit + fee = true default: return c, fmt.Errorf("Unexpected PoolL2 tx type: %s", lit) }

@@ -450,7 +458,7 @@ c.loadAmount = uint64(amount)

} else { c.amount = uint64(amount) } - if transferring { + if fee { if err := p.expectChar(c, "("); err != nil { return c, err }
M test/til/lang_test.go → test/til/lang_test.go

@@ -24,7 +24,7 @@ Deposit(1) A: 10

Deposit(2) A: 20 Deposit(1) B: 5 CreateAccountDeposit(1) C: 5 - CreateAccountDepositTransfer(1) D-A: 15, 10 (3) + CreateAccountDepositTransfer(1) D-A: 15, 10 CreateAccountDepositCoordinator(1) E // L2 transactions

@@ -36,7 +36,7 @@ // set new batch

> batch AddToken(3) - DepositTransfer(1) A-B: 15, 10 (1) + DepositTransfer(1) A-B: 15, 10 Transfer(1) C-A : 3 (1) Transfer(2) A-B: 15 (1)

@@ -53,7 +53,7 @@ > batch

> block // Exits - Exit(1) A: 5 + Exit(1) A: 5 (1) ` parser := newParser(strings.NewReader(s))

@@ -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: 1, TokenID: 1\n", instructions.instructions[13].String()) + 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: 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())

@@ -87,7 +87,7 @@ PoolTransfer(1) A-B: 6 (1)

PoolTransfer(2) A-B: 3 (3) PoolTransfer(1) B-D: 3 (1) PoolTransfer(1) C-D: 3 (1) - PoolExit(1) A: 5 + PoolExit(1) A: 5 (1) ` parser := newParser(strings.NewReader(s))
M test/til/sets.go → test/til/sets.go

@@ -130,10 +130,10 @@ Transfer(1) Y-E: 5 (1)

Transfer(1) Z-A: 5 (1) // exits ForceExit(1) A: 5 -Exit(1) K: 5 -Exit(1) X: 5 -Exit(1) Y: 5 -Exit(1) Z: 5 +Exit(1) K: 5 (1) +Exit(1) X: 5 (1) +Exit(1) Y: 5 (1) +Exit(1) Z: 5 (1) > batch

@@ -153,7 +153,7 @@ Transfer(1) B-N: 5 (1)

Transfer(1) C-O: 5 (1) Transfer(1) H-O: 5 (1) Transfer(1) I-H: 5 (1) -Exit(1) A: 5 +Exit(1) A: 5 (1) // create CoordinatorTx CreateAccount for D, TokenId 2, used at SetPool0 for 'PoolTransfer(2) B-D: 3 (1)' CreateAccountDepositCoordinator(2) D

@@ -172,7 +172,7 @@ PoolTransfer(1) C-A: 3 (1)

PoolTransfer(1) A-B: 1 (1) PoolTransfer(2) A-B: 15 (1) PoolTransfer(2) B-D: 3 (1) -PoolExit(1) A: 3 +PoolExit(1) A: 3 (1) PoolTransfer(1) A-B: 6 (1) PoolTransfer(1) B-C: 3 (1) PoolTransfer(1) A-C: 3 (1)
M test/til/txs_test.go → test/til/txs_test.go

@@ -46,7 +46,7 @@

> batchL1 // batchNum = 1 > batchL1 // batchNum = 2 - CreateAccountDepositTransfer(1) F-A: 15, 10 (3) + CreateAccountDepositTransfer(1) F-A: 15, 10 Transfer(1) A-B: 6 (1) Transfer(1) B-D: 3 (1)

@@ -57,7 +57,7 @@ > batch // batchNum = 3

CreateAccountDepositCoordinator(1) E CreateAccountDepositCoordinator(2) B - DepositTransfer(1) A-B: 15, 10 (1) + DepositTransfer(1) A-B: 15, 10 Transfer(1) C-A : 3 (1) Transfer(2) A-B: 15 (1) Transfer(1) A-E: 1 (1)

@@ -79,7 +79,7 @@ > block

// Exits Transfer(1) A-B: 1 (1) - Exit(1) A: 5 + Exit(1) A: 5 (1) > batch // batchNum = 6 > block

@@ -206,7 +206,7 @@ PoolTransfer(2) A-B: 15 (1)

PoolTransfer(1) User0-User1: 15 (1) PoolTransfer(3) User1-User0: 15 (1) PoolTransfer(2) B-D: 3 (1) - PoolExit(1) A: 3 + PoolExit(1) A: 3 (1) PoolTransferToEthAddr(1) A-B: 1 (1) PoolTransferToBJJ(1) A-B: 1 (1) `

@@ -350,7 +350,7 @@ > batchL1

Transfer(1) A-B: 6 (1) Transfer(1) A-B: 6 (1) // on purpose this is moving more money that what it has in the account, Til should not fail Transfer(1) B-A: 6 (1) - Exit(1) A: 3 + Exit(1) A: 3 (1) > batch ` tc = NewContext(eth.RollupConstMaxL1UserTx)