arnaucube
arnaucube/hermez-nodePublic Self-hosted repository
Update importers of eth, use variable length feeIdxCoordinator
Eduard S eduard@iden3.io
Wed, 14 Oct 2020 13:22:23 +0200
commit

9684e7ae473d76bf2128e4426863c752ead905a0

parent

a405ab3a20bb4ea915abeece77bfdaa55737c425

5 files changed, 130 insertions(+), 216 deletions(-)

jump to
M eth/rollup.go → eth/rollup.go

@@ -22,6 +22,11 @@ "golang.org/x/crypto/sha3"

) const ( + // RollupConstMaxFeeIdxCoordinator is the maximum number of tokens the + // coordinator can use to collect fees (determines the number of tokens + // that the coordinator can collect fees from). This value is + // determined by the circuit. + RollupConstMaxFeeIdxCoordinator = 64 // RollupConstReservedIDx First 256 indexes reserved, first user index will be the 256 RollupConstReservedIDx = 255 // RollupConstExitIDx IDX 1 is reserved for exits

@@ -174,7 +179,7 @@ }

// RollupEventUpdateForgeL1L2BatchTimeout is an event of the Rollup Smart Contract type RollupEventUpdateForgeL1L2BatchTimeout struct { - NewForgeL1L2BatchTimeout uint8 + NewForgeL1L2BatchTimeout int64 } // RollupEventUpdateFeeAddToken is an event of the Rollup Smart Contract

@@ -216,9 +221,9 @@ type RollupForgeBatchArgs struct {

NewLastIdx int64 NewStRoot *big.Int NewExitRoot *big.Int - L1CoordinatorTxs []*common.L1Tx + L1CoordinatorTxs []common.L1Tx L1CoordinatorTxsAuths [][]byte // Authorization for accountCreations for each L1CoordinatorTx - L2TxsData []*common.L2Tx + L2TxsData []common.L2Tx FeeIdxCoordinator []common.Idx // Circuit selector VerifierIdx uint8

@@ -262,7 +267,7 @@ RollupL1UserTxERC20ETH(fromBJJ *babyjub.PublicKey, fromIdx int64, loadAmount *big.Int, amount *big.Int, tokenID uint32, toIdx int64) (*types.Transaction, error)

RollupL1UserTxERC777(fromBJJ *babyjub.PublicKey, fromIdx int64, loadAmount *big.Int, amount *big.Int, tokenID uint32, toIdx int64) (*types.Transaction, error) // Governance Public Functions - RollupUpdateForgeL1L2BatchTimeout(newForgeL1L2BatchTimeout uint8) (*types.Transaction, error) + RollupUpdateForgeL1L2BatchTimeout(newForgeL1L2BatchTimeout int64) (*types.Transaction, error) RollupUpdateFeeAddToken(newFeeAddToken *big.Int) (*types.Transaction, error) // Viewers

@@ -283,25 +288,25 @@ //

// RollupClient is the implementation of the interface to the Rollup Smart Contract in ethereum. type RollupClient struct { - client *EthereumClient - address ethCommon.Address - tokenAddress ethCommon.Address - gasLimit uint64 - contractAbi abi.ABI + client *EthereumClient + address ethCommon.Address + tokenHEZAddress ethCommon.Address + gasLimit uint64 + contractAbi abi.ABI } // NewRollupClient creates a new RollupClient -func NewRollupClient(client *EthereumClient, address ethCommon.Address, tokenAddress ethCommon.Address) (*RollupClient, error) { +func NewRollupClient(client *EthereumClient, address ethCommon.Address, tokenHEZAddress ethCommon.Address) (*RollupClient, error) { contractAbi, err := abi.JSON(strings.NewReader(string(Hermez.HermezABI))) if err != nil { return nil, err } return &RollupClient{ - client: client, - address: address, - tokenAddress: tokenAddress, - gasLimit: 1000000, //nolint:gomnd - contractAbi: contractAbi, + client: client, + address: address, + tokenHEZAddress: tokenHEZAddress, + gasLimit: 1000000, //nolint:gomnd + contractAbi: contractAbi, }, nil }

@@ -321,7 +326,7 @@ if err != nil {

return nil, err } nLevels := rollupConst.Verifiers[args.VerifierIdx].NLevels - lenBytes := nLevels / 8 + lenBytes := nLevels / 8 //nolint:gomnd newLastIdx := big.NewInt(int64(args.NewLastIdx)) var l1CoordinatorBytes []byte for i := 0; i < len(args.L1CoordinatorTxs); i++ {

@@ -342,8 +347,15 @@ }

l2DataBytes = append(l2DataBytes, bytesl2[:]...) } var feeIdxCoordinator []byte - for i := 0; i < len(args.FeeIdxCoordinator); i++ { - feeIdx := args.FeeIdxCoordinator[i] + if len(args.FeeIdxCoordinator) > RollupConstMaxFeeIdxCoordinator { + return nil, fmt.Errorf("len(args.FeeIdxCoordinator) > %v", + RollupConstMaxFeeIdxCoordinator) + } + for i := 0; i < RollupConstMaxFeeIdxCoordinator; i++ { + feeIdx := common.Idx(0) + if i < len(args.FeeIdxCoordinator) { + feeIdx = args.FeeIdxCoordinator[i] + } bytesFeeIdx, err := feeIdx.Bytes() if err != nil { return nil, err

@@ -358,14 +370,16 @@ }

return tx, nil } -// RollupAddToken is the interface to call the smart contract function +// RollupAddToken is the interface to call the smart contract function. +// `feeAddToken` is the amount of HEZ tokens that will be paid to add the +// token. `feeAddToken` must match the public value of the smart contract. func (c *RollupClient) RollupAddToken(tokenAddress ethCommon.Address, feeAddToken *big.Int) (*types.Transaction, error) { var tx *types.Transaction var err error if tx, err = c.client.CallAuth( c.gasLimit, func(ec *ethclient.Client, auth *bind.TransactOpts) (*types.Transaction, error) { - tokens, err := ERC777.NewERC777(c.tokenAddress, ec) + tokens, err := ERC777.NewERC777(c.tokenHEZAddress, ec) if err != nil { return nil, err }

@@ -440,6 +454,9 @@ if err != nil {

return nil, err } amountF, err := common.NewFloat16(amount) + if err != nil { + return nil, err + } if tokenID == 0 { auth.Value = loadAmount }

@@ -458,7 +475,7 @@ var err error

if tx, err = c.client.CallAuth( c.gasLimit, func(ec *ethclient.Client, auth *bind.TransactOpts) (*types.Transaction, error) { - tokens, err := ERC777.NewERC777(c.tokenAddress, ec) + tokens, err := ERC777.NewERC777(c.tokenHEZAddress, ec) if err != nil { return nil, err }

@@ -527,7 +544,7 @@ return registerTokensCount, nil

} // RollupUpdateForgeL1L2BatchTimeout is the interface to call the smart contract function -func (c *RollupClient) RollupUpdateForgeL1L2BatchTimeout(newForgeL1L2BatchTimeout uint8) (*types.Transaction, error) { +func (c *RollupClient) RollupUpdateForgeL1L2BatchTimeout(newForgeL1L2BatchTimeout int64) (*types.Transaction, error) { var tx *types.Transaction var err error if tx, err = c.client.CallAuth(

@@ -537,7 +554,7 @@ hermez, err := Hermez.NewHermez(c.address, ec)

if err != nil { return nil, err } - return hermez.UpdateForgeL1L2BatchTimeout(auth, newForgeL1L2BatchTimeout) + return hermez.UpdateForgeL1L2BatchTimeout(auth, uint8(newForgeL1L2BatchTimeout)) }, ); err != nil { return nil, fmt.Errorf("Failed update ForgeL1L2BatchTimeout: %w", err)

@@ -651,12 +668,10 @@ var L1UserTxAux RollupEventL1UserTxAux

var L1UserTx RollupEventL1UserTx err := c.contractAbi.Unpack(&L1UserTxAux, "L1UserTxEvent", vLog.Data) if err != nil { - fmt.Println(err) return nil, nil, err } L1Tx, err := common.L1TxFromBytes(L1UserTxAux.L1UserTx) if err != nil { - fmt.Println(err) return nil, nil, err } L1UserTx.ToForgeL1TxsNum = new(big.Int).SetBytes(vLog.Topics[1][:]).Int64()

@@ -677,12 +692,17 @@ forgeBatch.BatchNum = new(big.Int).SetBytes(vLog.Topics[1][:]).Int64()

forgeBatch.EthTxHash = vLog.TxHash rollupEvents.ForgeBatch = append(rollupEvents.ForgeBatch, forgeBatch) case logHermezUpdateForgeL1L2BatchTimeout: - var updateForgeL1L2BatchTimeout RollupEventUpdateForgeL1L2BatchTimeout + var updateForgeL1L2BatchTimeout struct { + NewForgeL1L2BatchTimeout uint8 + } err := c.contractAbi.Unpack(&updateForgeL1L2BatchTimeout, "UpdateForgeL1L2BatchTimeout", vLog.Data) if err != nil { return nil, nil, err } - rollupEvents.UpdateForgeL1L2BatchTimeout = append(rollupEvents.UpdateForgeL1L2BatchTimeout, updateForgeL1L2BatchTimeout) + rollupEvents.UpdateForgeL1L2BatchTimeout = append(rollupEvents.UpdateForgeL1L2BatchTimeout, + RollupEventUpdateForgeL1L2BatchTimeout{ + NewForgeL1L2BatchTimeout: int64(updateForgeL1L2BatchTimeout.NewForgeL1L2BatchTimeout), + }) case logHermezUpdateFeeAddToken: var updateFeeAddToken RollupEventUpdateFeeAddToken err := c.contractAbi.Unpack(&updateFeeAddToken, "UpdateFeeAddToken", vLog.Data)

@@ -719,15 +739,20 @@ var aux RollupForgeBatchArgsAux

if err := method.Inputs.Unpack(&aux, txData[4:]); err != nil { return nil, err } - var rollupForgeBatchArgs RollupForgeBatchArgs - rollupForgeBatchArgs.L1Batch = aux.L1Batch - rollupForgeBatchArgs.NewExitRoot = aux.NewExitRoot - rollupForgeBatchArgs.NewLastIdx = aux.NewLastIdx.Int64() - rollupForgeBatchArgs.NewStRoot = aux.NewStRoot - rollupForgeBatchArgs.ProofA = aux.ProofA - rollupForgeBatchArgs.ProofB = aux.ProofB - rollupForgeBatchArgs.ProofC = aux.ProofC - rollupForgeBatchArgs.VerifierIdx = aux.VerifierIdx + rollupForgeBatchArgs := RollupForgeBatchArgs{ + L1Batch: aux.L1Batch, + NewExitRoot: aux.NewExitRoot, + NewLastIdx: aux.NewLastIdx.Int64(), + NewStRoot: aux.NewStRoot, + ProofA: aux.ProofA, + ProofB: aux.ProofB, + ProofC: aux.ProofC, + VerifierIdx: aux.VerifierIdx, + L1CoordinatorTxs: []common.L1Tx{}, + L1CoordinatorTxsAuths: [][]byte{}, + L2TxsData: []common.L2Tx{}, + FeeIdxCoordinator: []common.Idx{}, + } numTxsL1 := len(aux.EncodedL1CoordinatorTx) / common.L1CoordinatorTxBytesLen for i := 0; i < numTxsL1; i++ { bytesL1Coordinator := aux.EncodedL1CoordinatorTx[i*common.L1CoordinatorTxBytesLen : (i+1)*common.L1CoordinatorTxBytesLen]

@@ -742,7 +767,7 @@ l1Tx, err := common.L1TxFromCoordinatorBytes(bytesL1Coordinator)

if err != nil { return nil, err } - rollupForgeBatchArgs.L1CoordinatorTxs = append(rollupForgeBatchArgs.L1CoordinatorTxs, l1Tx) + rollupForgeBatchArgs.L1CoordinatorTxs = append(rollupForgeBatchArgs.L1CoordinatorTxs, *l1Tx) rollupForgeBatchArgs.L1CoordinatorTxsAuths = append(rollupForgeBatchArgs.L1CoordinatorTxsAuths, signature) } rollupConsts, err := c.RollupConstants()

@@ -757,7 +782,7 @@ l2Tx, err := common.L2TxFromBytes(aux.L2TxsData[i*lenL2TxsBytes:(i+1)*lenL2TxsBytes], int(nLevels))

if err != nil { return nil, err } - rollupForgeBatchArgs.L2TxsData = append(rollupForgeBatchArgs.L2TxsData, l2Tx) + rollupForgeBatchArgs.L2TxsData = append(rollupForgeBatchArgs.L2TxsData, *l2Tx) } lenFeeIdxCoordinatorBytes := int(nLevels / 8) //nolint:gomnd numFeeIdxCoordinator := len(aux.FeeIdxCoordinator) / lenFeeIdxCoordinatorBytes

@@ -769,11 +794,13 @@ copy(paddedFeeIdx[6-lenFeeIdxCoordinatorBytes:], aux.FeeIdxCoordinator[i*lenFeeIdxCoordinatorBytes:(i+1)*lenFeeIdxCoordinatorBytes])

} else { copy(paddedFeeIdx[:], aux.FeeIdxCoordinator[i*lenFeeIdxCoordinatorBytes:(i+1)*lenFeeIdxCoordinatorBytes]) } - FeeIdxCoordinator, err := common.IdxFromBytes(paddedFeeIdx[:]) + feeIdxCoordinator, err := common.IdxFromBytes(paddedFeeIdx[:]) if err != nil { return nil, err } - rollupForgeBatchArgs.FeeIdxCoordinator = append(rollupForgeBatchArgs.FeeIdxCoordinator, FeeIdxCoordinator) + if feeIdxCoordinator != common.Idx(0) { + rollupForgeBatchArgs.FeeIdxCoordinator = append(rollupForgeBatchArgs.FeeIdxCoordinator, feeIdxCoordinator) + } } return &rollupForgeBatchArgs, nil }
M eth/rollup_test.go → eth/rollup_test.go

@@ -71,8 +71,7 @@ assert.Equal(t, big.NewInt(1), registerTokensCount)

} func TestAddToken(t *testing.T) { - var feeAddToken = new(big.Int) - feeAddToken = big.NewInt(10) + feeAddToken := big.NewInt(10) // Addtoken ERC20 registerTokensCount, err := rollupClient.RollupRegisterTokensCount() require.Nil(t, err)

@@ -125,21 +124,22 @@ addBlocks(blocksToAdd, ethClientDialURL)

// Forge args := new(RollupForgeBatchArgs) - feeIdxCoordinatorBytes, err := hex.DecodeString("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000") - require.Nil(t, err) - lenFeeIdxCoordinatorBytes := int(4) - numFeeIdxCoordinator := len(feeIdxCoordinatorBytes) / lenFeeIdxCoordinatorBytes - for i := 0; i < numFeeIdxCoordinator; i++ { - var paddedFeeIdx [6]byte - if lenFeeIdxCoordinatorBytes < common.IdxBytesLen { - copy(paddedFeeIdx[6-lenFeeIdxCoordinatorBytes:], feeIdxCoordinatorBytes[i*lenFeeIdxCoordinatorBytes:(i+1)*lenFeeIdxCoordinatorBytes]) - } else { - copy(paddedFeeIdx[:], feeIdxCoordinatorBytes[i*lenFeeIdxCoordinatorBytes:(i+1)*lenFeeIdxCoordinatorBytes]) - } - FeeIdxCoordinator, err := common.IdxFromBytes(paddedFeeIdx[:]) - require.Nil(t, err) - args.FeeIdxCoordinator = append(args.FeeIdxCoordinator, FeeIdxCoordinator) - } + // feeIdxCoordinatorBytes, err := hex.DecodeString("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000") + // require.Nil(t, err) + // lenFeeIdxCoordinatorBytes := int(4) + // numFeeIdxCoordinator := len(feeIdxCoordinatorBytes) / lenFeeIdxCoordinatorBytes + // for i := 0; i < numFeeIdxCoordinator; i++ { + // var paddedFeeIdx [6]byte + // if lenFeeIdxCoordinatorBytes < common.IdxBytesLen { + // copy(paddedFeeIdx[6-lenFeeIdxCoordinatorBytes:], feeIdxCoordinatorBytes[i*lenFeeIdxCoordinatorBytes:(i+1)*lenFeeIdxCoordinatorBytes]) + // } else { + // copy(paddedFeeIdx[:], feeIdxCoordinatorBytes[i*lenFeeIdxCoordinatorBytes:(i+1)*lenFeeIdxCoordinatorBytes]) + // } + // FeeIdxCoordinator, err := common.IdxFromBytes(paddedFeeIdx[:]) + // require.Nil(t, err) + // args.FeeIdxCoordinator = append(args.FeeIdxCoordinator, FeeIdxCoordinator) + // } + args.FeeIdxCoordinator = []common.Idx{} // When encoded, 64 times the 0 idx means that no idx to collect fees is specified. l1CoordinatorBytes, err := hex.DecodeString("1c660323607bb113e586183609964a333d07ebe4bef3be82ec13af453bae9590bd7711cdb6abf42f176eadfbe5506fbef5e092e5543733f91b0061d9a7747fa10694a915a6470fa230de387b51e6f4db0b09787867778687b55197ad6d6a86eac000000001") require.Nil(t, err) numTxsL1 := len(l1CoordinatorBytes) / common.L1CoordinatorTxBytesLen

@@ -152,11 +152,12 @@ r := bytesL1Coordinator[33:65]

signature = append(signature, r[:]...) signature = append(signature, s[:]...) signature = append(signature, v) - L1Tx, err := common.L1TxFromCoordinatorBytes(bytesL1Coordinator) + l1Tx, err := common.L1TxFromCoordinatorBytes(bytesL1Coordinator) require.Nil(t, err) - args.L1CoordinatorTxs = append(args.L1CoordinatorTxs, L1Tx) + args.L1CoordinatorTxs = append(args.L1CoordinatorTxs, *l1Tx) args.L1CoordinatorTxsAuths = append(args.L1CoordinatorTxsAuths, signature) } + args.L2TxsData = []common.L2Tx{} newStateRoot := new(big.Int) newStateRoot.SetString("18317824016047294649053625209337295956588174734569560016974612130063629505228", 10) newExitRoot := new(big.Int)

@@ -202,7 +203,7 @@ assert.Equal(t, argsForge.VerifierIdx, args.VerifierIdx)

} func TestRollupUpdateForgeL1L2BatchTimeout(t *testing.T) { - newForgeL1L2BatchTimeout := uint8(222) + newForgeL1L2BatchTimeout := int64(222) _, err := rollupClient.RollupUpdateForgeL1L2BatchTimeout(newForgeL1L2BatchTimeout) require.Nil(t, err)
M synchronizer/synchronizer.go → synchronizer/synchronizer.go

@@ -484,7 +484,7 @@ for _, evtAddToken := range rollupEvents.AddToken {

var token common.Token token.TokenID = common.TokenID(evtAddToken.TokenID) - token.EthAddr = evtAddToken.Address + token.EthAddr = evtAddToken.TokenAddress token.EthBlockNum = blockNum // TODO: Add external information consulting SC about it using Address

@@ -584,17 +584,17 @@

for _, evtL1UserTx := range eventsL1UserTx { // Fill aditional Tx fields toForge := evtL1UserTx.ToForgeL1TxsNum - evtL1UserTx.L1Tx.ToForgeL1TxsNum = &toForge - evtL1UserTx.L1Tx.Position = evtL1UserTx.Position - evtL1UserTx.L1Tx.UserOrigin = true - evtL1UserTx.L1Tx.EthBlockNum = blockNum - nL1Tx, err := common.NewL1Tx(&evtL1UserTx.L1Tx) + evtL1UserTx.L1UserTx.ToForgeL1TxsNum = &toForge + evtL1UserTx.L1UserTx.Position = evtL1UserTx.Position + evtL1UserTx.L1UserTx.UserOrigin = true + evtL1UserTx.L1UserTx.EthBlockNum = blockNum + nL1Tx, err := common.NewL1Tx(&evtL1UserTx.L1UserTx) if err != nil { return nil, err } - evtL1UserTx.L1Tx = *nL1Tx + evtL1UserTx.L1UserTx = *nL1Tx - l1Txs = append(l1Txs, evtL1UserTx.L1Tx) + l1Txs = append(l1Txs, evtL1UserTx.L1UserTx) } return l1Txs, nil }
M test/ethclient.go → test/ethclient.go

@@ -599,10 +599,40 @@ panic("l1Tx.TokenID + 1 > len(r.State.TokenList)")

} queue.L1TxQueue = append(queue.L1TxQueue, *l1Tx) r.Events.L1UserTx = append(r.Events.L1UserTx, eth.RollupEventL1UserTx{ - L1Tx: *l1Tx, + L1UserTx: *l1Tx, ToForgeL1TxsNum: r.State.LastToForgeL1TxsNum, Position: len(queue.L1TxQueue) - 1, }) +} + +// RollupL1UserTxERC20ETH is the interface to call the smart contract function +func (c *Client) RollupL1UserTxERC20ETH(fromBJJ *babyjub.PublicKey, fromIdx int64, loadAmount *big.Int, amount *big.Int, tokenID uint32, toIdx int64) (*types.Transaction, error) { + log.Error("TODO") + return nil, errTODO +} + +// RollupL1UserTxERC777 is the interface to call the smart contract function +func (c *Client) RollupL1UserTxERC777(fromBJJ *babyjub.PublicKey, fromIdx int64, loadAmount *big.Int, amount *big.Int, tokenID uint32, toIdx int64) (*types.Transaction, error) { + log.Error("TODO") + return nil, errTODO +} + +// RollupRegisterTokensCount is the interface to call the smart contract function +func (c *Client) RollupRegisterTokensCount() (*big.Int, error) { + log.Error("TODO") + return nil, errTODO +} + +// RollupWithdrawCircuit is the interface to call the smart contract function +func (c *Client) RollupWithdrawCircuit(proofA, proofC [2]*big.Int, proofB [2][2]*big.Int, tokenID uint32, numExitRoot, idx int64, amount *big.Int, instantWithdraw bool) (*types.Transaction, error) { + log.Error("TODO") + return nil, errTODO +} + +// RollupWithdrawMerkleProof is the interface to call the smart contract function +func (c *Client) RollupWithdrawMerkleProof(babyPubKey *babyjub.PublicKey, tokenID uint32, numExitRoot, idx int64, amount *big.Int, siblings []*big.Int, instantWithdraw bool) (*types.Transaction, error) { + log.Error("TODO") + return nil, errTODO } type transactionData struct {

@@ -710,72 +740,11 @@ }

r.State.TokenMap[tokenAddress] = true r.State.TokenList = append(r.State.TokenList, tokenAddress) - r.Events.AddToken = append(r.Events.AddToken, eth.RollupEventAddToken{Address: tokenAddress, + r.Events.AddToken = append(r.Events.AddToken, eth.RollupEventAddToken{TokenAddress: tokenAddress, TokenID: uint32(len(r.State.TokenList) - 1)}) return r.addTransaction(newTransaction("addtoken", tokenAddress)), nil } -// RollupWithdrawSNARK is the interface to call the smart contract function -// func (c *Client) RollupWithdrawSNARK() (*types.Transaction, error) { // TODO (Not defined in Hermez.sol) -// return nil, errTODO -// } - -// RollupWithdraw is the interface to call the smart contract function -func (c *Client) RollupWithdraw(tokenID int64, balance *big.Int, babyPubKey *babyjub.PublicKey, numExitRoot int64, siblings []*big.Int, idx int64, instantWithdraw bool) (tx *types.Transaction, err error) { - c.rw.Lock() - defer c.rw.Unlock() - cpy := c.nextBlock().copy() - defer func() { c.revertIfErr(err, cpy) }() - if c.addr == nil { - return nil, eth.ErrAccountNil - } - - log.Error("TODO") - return nil, errTODO -} - -// RollupForceExit is the interface to call the smart contract function -func (c *Client) RollupForceExit(fromIdx int64, amountF common.Float16, tokenID int64) (tx *types.Transaction, err error) { - c.rw.Lock() - defer c.rw.Unlock() - cpy := c.nextBlock().copy() - defer func() { c.revertIfErr(err, cpy) }() - if c.addr == nil { - return nil, eth.ErrAccountNil - } - - log.Error("TODO") - return nil, errTODO -} - -// RollupForceTransfer is the interface to call the smart contract function -func (c *Client) RollupForceTransfer(fromIdx int64, amountF common.Float16, tokenID, toIdx int64) (tx *types.Transaction, err error) { - c.rw.Lock() - defer c.rw.Unlock() - cpy := c.nextBlock().copy() - defer func() { c.revertIfErr(err, cpy) }() - if c.addr == nil { - return nil, eth.ErrAccountNil - } - - log.Error("TODO") - return nil, errTODO -} - -// RollupCreateAccountDepositTransfer is the interface to call the smart contract function -func (c *Client) RollupCreateAccountDepositTransfer(babyPubKey babyjub.PublicKey, loadAmountF, amountF common.Float16, tokenID int64, toIdx int64) (tx *types.Transaction, err error) { - c.rw.Lock() - defer c.rw.Unlock() - cpy := c.nextBlock().copy() - defer func() { c.revertIfErr(err, cpy) }() - if c.addr == nil { - return nil, eth.ErrAccountNil - } - - log.Error("TODO") - return nil, errTODO -} - // RollupGetCurrentTokens is the interface to call the smart contract function func (c *Client) RollupGetCurrentTokens() (*big.Int, error) { c.rw.RLock()

@@ -784,89 +753,6 @@

log.Error("TODO") return nil, errTODO } - -// RollupDepositTransfer is the interface to call the smart contract function -func (c *Client) RollupDepositTransfer(fromIdx int64, loadAmountF, amountF common.Float16, tokenID int64, toIdx int64) (tx *types.Transaction, err error) { - c.rw.Lock() - defer c.rw.Unlock() - cpy := c.nextBlock().copy() - defer func() { c.revertIfErr(err, cpy) }() - if c.addr == nil { - return nil, eth.ErrAccountNil - } - - log.Error("TODO") - return nil, errTODO -} - -// RollupDeposit is the interface to call the smart contract function -func (c *Client) RollupDeposit(fromIdx int64, loadAmountF common.Float16, tokenID int64) (tx *types.Transaction, err error) { - c.rw.Lock() - defer c.rw.Unlock() - cpy := c.nextBlock().copy() - defer func() { c.revertIfErr(err, cpy) }() - if c.addr == nil { - return nil, eth.ErrAccountNil - } - - log.Error("TODO") - return nil, errTODO -} - -// RollupCreateAccountDepositFromRelayer is the interface to call the smart contract function -func (c *Client) RollupCreateAccountDepositFromRelayer(accountCreationAuthSig []byte, babyPubKey babyjub.PublicKey, loadAmountF common.Float16) (tx *types.Transaction, err error) { - c.rw.Lock() - defer c.rw.Unlock() - cpy := c.nextBlock().copy() - defer func() { c.revertIfErr(err, cpy) }() - if c.addr == nil { - return nil, eth.ErrAccountNil - } - - log.Error("TODO") - return nil, errTODO -} - -// RollupCreateAccountDeposit is the interface to call the smart contract function -func (c *Client) RollupCreateAccountDeposit(babyPubKey babyjub.PublicKey, loadAmountF common.Float16, tokenID int64) (tx *types.Transaction, err error) { - c.rw.Lock() - defer c.rw.Unlock() - cpy := c.nextBlock().copy() - defer func() { c.revertIfErr(err, cpy) }() - if c.addr == nil { - return nil, eth.ErrAccountNil - } - - log.Error("TODO") - return nil, errTODO -} - -// RollupGetTokenAddress is the interface to call the smart contract function -// func (c *Client) RollupGetTokenAddress(tokenID int64) (*ethCommon.Address, error) { -// c.rw.RLock() -// defer c.rw.RUnlock() -// -// log.Error("TODO") -// return nil, errTODO -// } - -// RollupGetL1TxFromQueue is the interface to call the smart contract function -// func (c *Client) RollupGetL1TxFromQueue(queue int64, position int64) ([]byte, error) { -// c.rw.RLock() -// defer c.rw.RUnlock() -// -// log.Error("TODO") -// return nil, errTODO -// } - -// RollupGetQueue is the interface to call the smart contract function -// func (c *Client) RollupGetQueue(queue int64) ([]byte, error) { -// c.rw.RLock() -// defer c.rw.RUnlock() -// -// log.Error("TODO") -// return nil, errTODO -// } // RollupUpdateForgeL1L2BatchTimeout is the interface to call the smart contract function func (c *Client) RollupUpdateForgeL1L2BatchTimeout(newForgeL1Timeout int64) (tx *types.Transaction, err error) {
M test/ethclient_test.go → test/ethclient_test.go

@@ -180,7 +180,7 @@ NewStRoot: big.NewInt(1),

NewExitRoot: big.NewInt(100), L1CoordinatorTxs: []common.L1Tx{}, L2TxsData: []common.L2Tx{}, - FeeIdxCoordinator: make([]common.Idx, eth.RollupConstFeeIdxCoordinatorLen), + FeeIdxCoordinator: []common.Idx{}, VerifierIdx: 0, L1Batch: true, })

@@ -217,7 +217,7 @@ NewStRoot: big.NewInt(1),

NewExitRoot: big.NewInt(100), L1CoordinatorTxs: []common.L1Tx{}, L2TxsData: []common.L2Tx{}, - FeeIdxCoordinator: make([]common.Idx, eth.RollupConstFeeIdxCoordinatorLen), + FeeIdxCoordinator: []common.Idx{}, VerifierIdx: 0, L1Batch: true, }