Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
badgersrus committed Oct 31, 2024
1 parent 8dccda3 commit 051aef9
Showing 1 changed file with 45 additions and 42 deletions.
87 changes: 45 additions & 42 deletions go/host/l1/publisher.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,56 +231,59 @@ func (p *Publisher) PublishSecretResponse(secretResponse *common.ProducedSecretR
// ExtractRelevantTenTransactions will extract any transactions from the block that are relevant to TEN
// todo (#2495) we should monitor for relevant L1 events instead of scanning every transaction in the block
func (p *Publisher) ExtractRelevantTenTransactions(block *types.Block, receipts types.Receipts) ([]*common.TxAndReceiptAndBlobs, []*ethadapter.L1RollupTx, []*ethadapter.L1SetImportantContractsTx) {
txWithReceiptsAndBlobs := make([]*common.TxAndReceiptAndBlobs, 0)
rollupTxs := make([]*ethadapter.L1RollupTx, 0)
contractAddressTxs := make([]*ethadapter.L1SetImportantContractsTx, 0)

txs := block.Transactions()
for i, rec := range receipts {
if rec.BlockNumber == nil {
continue // Skip non-relevant transactions
}
// temporarily add this host stopping check to prevent sim test failures until a more robust solution is implemented
for !p.hostStopper.IsStopping() {
txWithReceiptsAndBlobs := make([]*common.TxAndReceiptAndBlobs, 0)
rollupTxs := make([]*ethadapter.L1RollupTx, 0)
contractAddressTxs := make([]*ethadapter.L1SetImportantContractsTx, 0)

txs := block.Transactions()
for i, rec := range receipts {
if rec.BlockNumber == nil {
continue // Skip non-relevant transactions
}

decodedTx := p.mgmtContractLib.DecodeTx(txs[i])
var blobs []*kzg4844.Blob
var err error

decodedTx := p.mgmtContractLib.DecodeTx(txs[i])
var blobs []*kzg4844.Blob
var err error

switch typedTx := decodedTx.(type) {
case *ethadapter.L1SetImportantContractsTx:
contractAddressTxs = append(contractAddressTxs, typedTx)
case *ethadapter.L1RollupHashes:
blobs, err = p.blobResolver.FetchBlobs(p.sendingContext, block.Header(), typedTx.BlobHashes)
// temporarily add this host stopping check to prevent sim test failures until a more robust solution is implemented
if err != nil && !p.hostStopper.IsStopping() {
if errors.Is(err, ethereum.NotFound) {
p.logger.Crit("Blobs were not found on beacon chain or archive service", "block", block.Hash(), "error", err)
} else {
p.logger.Crit("could not fetch blobs", log.ErrKey, err)
switch typedTx := decodedTx.(type) {
case *ethadapter.L1SetImportantContractsTx:
contractAddressTxs = append(contractAddressTxs, typedTx)
case *ethadapter.L1RollupHashes:
blobs, err = p.blobResolver.FetchBlobs(p.sendingContext, block.Header(), typedTx.BlobHashes)
// temporarily add this host stopping check to prevent sim test failures until a more robust solution is implemented
if err != nil {
if errors.Is(err, ethereum.NotFound) {
p.logger.Crit("Blobs were not found on beacon chain or archive service", "block", block.Hash(), "error", err)
} else {
p.logger.Crit("could not fetch blobs", log.ErrKey, err)
}
continue
}
continue
}

encodedRlp, err := ethadapter.DecodeBlobs(blobs)
if err != nil {
p.logger.Crit("could not decode blobs.", log.ErrKey, err)
continue
}
encodedRlp, err := ethadapter.DecodeBlobs(blobs)
if err != nil {
p.logger.Crit("could not decode blobs.", log.ErrKey, err)
continue
}

rlp := &ethadapter.L1RollupTx{
Rollup: encodedRlp,
rlp := &ethadapter.L1RollupTx{
Rollup: encodedRlp,
}
rollupTxs = append(rollupTxs, rlp)
}
rollupTxs = append(rollupTxs, rlp)

// compile the tx, receipt and blobs into a single struct for submission to the enclave
txWithReceiptsAndBlobs = append(txWithReceiptsAndBlobs, &common.TxAndReceiptAndBlobs{
Tx: txs[i],
Receipt: rec,
Blobs: blobs,
})
}

// compile the tx, receipt and blobs into a single struct for submission to the enclave
txWithReceiptsAndBlobs = append(txWithReceiptsAndBlobs, &common.TxAndReceiptAndBlobs{
Tx: txs[i],
Receipt: rec,
Blobs: blobs,
})
return txWithReceiptsAndBlobs, rollupTxs, contractAddressTxs
}

return txWithReceiptsAndBlobs, rollupTxs, contractAddressTxs
}

Check failure on line 287 in go/host/l1/publisher.go

View workflow job for this annotation

GitHub Actions / lint

missing return) (typecheck)

Check failure on line 287 in go/host/l1/publisher.go

View workflow job for this annotation

GitHub Actions / lint

missing return) (typecheck)

Check failure on line 287 in go/host/l1/publisher.go

View workflow job for this annotation

GitHub Actions / lint

missing return) (typecheck)

Check failure on line 287 in go/host/l1/publisher.go

View workflow job for this annotation

GitHub Actions / lint

missing return (typecheck)

Check failure on line 287 in go/host/l1/publisher.go

View workflow job for this annotation

GitHub Actions / build

missing return

// FindSecretResponseTx will scan the block for any secret response transactions. This is separate from the above method
Expand Down

0 comments on commit 051aef9

Please sign in to comment.