Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

generate receipt refactor #3436

Merged
merged 3 commits into from
Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ services:
zkevm-prover:
container_name: zkevm-prover
restart: unless-stopped
image: hermeznetwork/zkevm-prover:v5.0.3
image: hermeznetwork/zkevm-prover:v5.0.4
depends_on:
zkevm-state-db:
condition: service_healthy
Expand Down
4 changes: 2 additions & 2 deletions state/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ func DecodeTx(encodedTx string) (*types.Transaction, error) {
}

// GenerateReceipt generates a receipt from a processed transaction
func GenerateReceipt(blockNumber *big.Int, processedTx *ProcessTransactionResponse, txIndex uint, forkID uint64) (*types.Receipt, common.Hash) {
func GenerateReceipt(blockNumber *big.Int, processedTx *ProcessTransactionResponse, txIndex uint, forkID uint64) *types.Receipt {
receipt := &types.Receipt{
Type: uint8(processedTx.Type),
BlockNumber: blockNumber,
Expand Down Expand Up @@ -323,7 +323,7 @@ func GenerateReceipt(blockNumber *big.Int, processedTx *ProcessTransactionRespon
receipt.Status = uint64(processedTx.Status)
}

return receipt, processedTx.StateRoot
return receipt
}

// IsPreEIP155Tx checks if the tx is a tx that has a chainID as zero and
Expand Down
2 changes: 1 addition & 1 deletion state/runtime/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ var (
// ErrExecutorErrorInvalidUpdateMerkleTree indicates that the input parameter update merkle tree is invalid
ErrExecutorErrorInvalidUpdateMerkleTree = errors.New("invalid update merkle tree")
// ErrExecutorErrorSMMainInvalidTxStatusError indicates that the TX has an invalid status-error combination
ErrExecutorErrorSMMainInvalidTxStatusError = errors.New("TX has an invalid status-error combination")
ErrExecutorErrorSMMainInvalidTxStatusError = errors.New("tx has an invalid status-error combination")

// GRPC ERRORS
// ===========
Expand Down
13 changes: 6 additions & 7 deletions state/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,12 +169,12 @@ func (s *State) StoreTransactions(ctx context.Context, batchNumber uint64, proce
header.BlockInfoRoot = processedBlock.BlockInfoRoot
transactions := []*types.Transaction{&processedTx.Tx}

receipt, imStateRoot := GenerateReceipt(header.Number, processedTx, uint(i), forkID)
receipt := GenerateReceipt(header.Number, processedTx, uint(i), forkID)
if !CheckLogOrder(receipt.Logs) {
return fmt.Errorf("error: logs received from executor are not in order")
}
receipts := []*types.Receipt{receipt}
imStateRoots := []common.Hash{imStateRoot}
imStateRoots := []common.Hash{processedTx.StateRoot}

// Create l2Block to be able to calculate its hash
st := trie.NewStackTrie(nil)
Expand Down Expand Up @@ -241,7 +241,6 @@ func (s *State) StoreL2Block(ctx context.Context, batchNumber uint64, l2Block *P
receipts := make([]*types.Receipt, 0, numTxs)
txsL2Hash := make([]common.Hash, 0, numTxs)
imStateRoots := make([]common.Hash, 0, numTxs)
var imStateRoot common.Hash
var receipt *types.Receipt

for i, txResponse := range l2Block.TransactionResponses {
Expand All @@ -265,9 +264,9 @@ func (s *State) StoreL2Block(ctx context.Context, batchNumber uint64, l2Block *P

storeTxsEGPData = append(storeTxsEGPData, storeTxEGPData)

receipt, imStateRoot = GenerateReceipt(header.Number, txResponse, uint(i), forkID)
receipt = GenerateReceipt(header.Number, txResponse, uint(i), forkID)
receipts = append(receipts, receipt)
imStateRoots = append(imStateRoots, imStateRoot)
imStateRoots = append(imStateRoots, txResp.StateRoot)
}

// Create block to be able to calculate its hash
Expand Down Expand Up @@ -667,9 +666,9 @@ func (s *State) StoreTransaction(ctx context.Context, batchNumber uint64, proces
header.BlockInfoRoot = blockInfoRoot
transactions := []*types.Transaction{&processedTx.Tx}

receipt, imStateRoot := GenerateReceipt(header.Number, processedTx, 0, forkID)
receipt := GenerateReceipt(header.Number, processedTx, 0, forkID)
receipts := []*types.Receipt{receipt}
imStateRoots := []common.Hash{imStateRoot}
imStateRoots := []common.Hash{processedTx.StateRoot}

// Create l2Block to be able to calculate its hash
st := trie.NewStackTrie(nil)
Expand Down
4 changes: 2 additions & 2 deletions test/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ services:

zkevm-prover:
container_name: zkevm-prover
image: hermeznetwork/zkevm-prover:v5.0.3
image: hermeznetwork/zkevm-prover:v5.0.4
ports:
- 50061:50061 # MT
- 50071:50071 # Executor
Expand Down Expand Up @@ -602,7 +602,7 @@ services:

zkevm-permissionless-prover:
container_name: zkevm-permissionless-prover
image: hermeznetwork/zkevm-prover:v5.0.3
image: hermeznetwork/zkevm-prover:v5.0.4
ports:
# - 50058:50058 # Prover
- 50059:50052 # Mock prover
Expand Down
Loading