Skip to content

Commit

Permalink
Release/1.1.5.5 (#709)
Browse files Browse the repository at this point in the history
* fix(zkevm_api): getBatchByNumber l2hashes

* fix(zkevm_api): getBatchByNumber oldAccInputHash

---------

Co-authored-by: Max Revitt <max@revitt.consulting>
  • Loading branch information
hexoscott and revitteth authored Jul 4, 2024
1 parent 59dde5a commit 2a20a2f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 9 deletions.
33 changes: 24 additions & 9 deletions cmd/rpcdaemon/commands/zkevm_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,25 @@ func (api *ZkEvmAPIImpl) GetBatchByNumber(ctx context.Context, batchNumber rpc.B
// txs
hashes := make([]types.TransactionOrHash, len(bbj.Transactions))
for i, txn := range bbj.Transactions {
// TODO: add transactionl2hash

blkTx := blk.Transactions()[i]
l2TxHash, err := zktx.ComputeL2TxHash(
blkTx.GetChainID().ToBig(),
blkTx.GetValue(),
blkTx.GetPrice(),
blkTx.GetNonce(),
blkTx.GetGas(),
blkTx.GetTo(),
&txn.Tx.From,
blkTx.GetData(),
)
if err != nil {
return nil, err
}

txn.Tx.L2Hash = l2TxHash
txn.Tx.Receipt.TransactionL2Hash = l2TxHash

batchTransactionsJson = append(batchTransactionsJson, txn)
txn.Hash = &txn.Tx.Hash
txn.Tx = nil
Expand All @@ -485,8 +503,6 @@ func (api *ZkEvmAPIImpl) GetBatchByNumber(ctx context.Context, batchNumber rpc.B
// after collecting transactions, reduce them to them hash only on the block
bbj.Transactions = hashes

// TODO: add l2hash

batchBlocksJson = append(batchBlocksJson, batchBlockExtra)
}

Expand Down Expand Up @@ -616,12 +632,11 @@ func (api *ZkEvmAPIImpl) GetBatchByNumber(ctx context.Context, batchNumber rpc.B
}
batch.BatchL2Data = batchL2Data

// currently gives 'error execution reverted' when calling the L1
//oaih, err := api.l1Syncer.GetOldAccInputHash(ctx, &api.config.AddressRollup, ApiRollupId, bn+1)
//if err != nil {
// return nil, err
//}
//batch.AccInputHash = oaih
oldAccInputHash, err := api.l1Syncer.GetOldAccInputHash(ctx, &api.config.AddressRollup, ApiRollupId, batchNo)
if err != nil {
return nil, err
}
batch.AccInputHash = oldAccInputHash

return populateBatchDetails(batch)
}
Expand Down
2 changes: 2 additions & 0 deletions zk/rpcdaemon/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,7 @@ type Transaction struct {
ChainID ArgBig `json:"chainId"`
Type ArgUint64 `json:"type"`
Receipt *Receipt `json:"receipt,omitempty"`
L2Hash common.Hash `json:"l2Hash,omitempty"`
}

// GetSender gets the sender from the transaction's signature
Expand Down Expand Up @@ -482,6 +483,7 @@ type Receipt struct {
ContractAddress *common.Address `json:"contractAddress"`
Type ArgUint64 `json:"type"`
EffectiveGasPrice *ArgBig `json:"effectiveGasPrice,omitempty"`
TransactionL2Hash common.Hash `json:"transactionL2Hash,omitempty"`
}

// NewReceipt creates a new Receipt instance
Expand Down

0 comments on commit 2a20a2f

Please sign in to comment.