You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
Eduard S b1a8384f27 Run go-instrument-errors to wrap errors 3 years ago
..
README.md Add HashGlobalInputs for ZKInputs 4 years ago
lang.go Rename load amount to deposit amount 4 years ago
lang_test.go Rename load amount to deposit amount 4 years ago
sets.go Update Common & StateDB & ZKInputs to last protocol version 4 years ago
sets_test.go Reorganize smart contract types, udate eth tests, etc. 4 years ago
txs.go Run go-instrument-errors to wrap errors 3 years ago
txs_test.go Rename load amount to deposit amount 4 years ago

README.md

Til (Test instructions language)

Language to define sets of instructions to simulate Hermez transactions (L1 & L2) with real data.

Syntax

Global

  • Set type definition
    • Blockchain: generate the transactions that would come from the Hermez smart contract on the blockchain.
    Type: Blockchain
    
     - PoolL2: generate the transactions that would come from the Pool of L2Txs
    
     Type: PoolL2
    
    
    

Blockchain set of instructions

Available instructions:

Type: Blockchain

// add the TokenID:
AddToken(1)

// deposit of TokenID=1, on the account of tokenID=1 for the user A, of an
// amount of 50 units
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
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
CreateAccountCoordinator(2) User0


// deposit of TokenID=1, at the account A, of 6 units
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
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, 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. 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
ForceExit(1) A: 5

// advance one batch, forging without L1UserTxs, only can contain L2Txs and
// L1CoordinatorTxs
> batch

// advance one batch, forging with L1UserTxs (and L2Txs and L1CoordinatorTxs)
> batchL1

// advance an ethereum block
> block

PoolL2 set of instructions

Available instructions:

Type: PoolL2

// 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, paying a
// fee of 1
PoolExit(1) A: 3 (1)

Usage

// create a new til.Context
tc := til.NewContext(eth.RollupConstMaxL1UserTx)

// generate Blockchain blocks data from the common.SetBlockcahin0 instructions set
blocks, err = tc.GenerateBlocks(common.SetBlockchainMinimumFlow0)
assert.Nil(t, err)

// generate PoolL2 transactions data from the common.SetPool0 instructions set
poolL2Txs, err = tc.GeneratePoolL2Txs(common.SetPoolL2MinimumFlow0)
assert.Nil(t, err)

Where blocks will contain:

// BatchData contains the information of a Batch
type BatchData struct {
    L1CoordinatorTxs     []common.L1Tx
    L2Txs                []common.L2Tx
    CreatedAccounts []common.Account
}

// BlockData contains the information of a Block
type BlockData struct {
    L1UserTxs        []common.L1Tx
    Batches          []BatchData
    RegisteredTokens []common.Token
}