Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
badgersrus committed Dec 18, 2024
1 parent 08a2ef8 commit 7b7fd7a
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 28 deletions.
13 changes: 6 additions & 7 deletions go/common/l1_transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,18 @@ const (
SetImportantContractsTx
)

// ProcessedL1Data is submitted to the enclave by the guardian
type ProcessedL1Data struct {
BlockHeader *types.Header
Events []L1Event
}

// L1Event represents a single event type and its associated transactions
type L1Event struct {
Type uint8
Txs []*L1TxData
}

// ProcessedL1Data is submitted to the enclave by the guardian
type ProcessedL1Data struct {
BlockHeader *types.Header
Events []L1Event // Changed from map to slice of L1Event
}

// L1TxData represents an L1 transaction that are relevant to us
type L1TxData struct {
Transaction *types.Transaction
Expand All @@ -51,7 +51,6 @@ func (tx *L1TxData) HasSequencerEnclaveID() bool {
func (p *ProcessedL1Data) AddEvent(txType L1TxType, tx *L1TxData) {
eventType := uint8(txType)

// Find existing event group
for i := range p.Events {
if p.Events[i].Type != eventType {
continue
Expand Down
6 changes: 0 additions & 6 deletions go/host/enclave/guardian.go
Original file line number Diff line number Diff line change
Expand Up @@ -468,12 +468,6 @@ func (g *Guardian) submitL1Block(block *common.L1Block, isLatest bool) (bool, er
g.logger.Debug("Unable to submit block, enclave is busy processing data")
return false, nil
}
//receipts, err := g.sl.L1Repo().FetchObscuroReceipts(block)
//if err != nil {
// g.submitDataLock.Unlock() // lock must be released before returning
// return false, fmt.Errorf("could not fetch obscuro receipts for block=%s - %w", block.Hash(), err)
//}
//txsReceiptsAndBlobs, rollupTxs, contractAddressTxs := g.sl.L1Publisher().ExtractRelevantTenTransactions(block, receipts)
processedData, err := g.sl.L1Repo().ExtractTenTransactions(block)
if err != nil {
g.submitDataLock.Unlock() // lock must be released before returning
Expand Down
19 changes: 6 additions & 13 deletions go/host/l1/blockrepository.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,12 +161,18 @@ func (r *Repository) ExtractTenTransactions(block *common.L1Block) (*common.Proc
}

for _, l := range logs {
if len(l.Topics) == 0 {
r.logger.Warn("Log has no topics", "txHash", l.TxHash)

Check failure on line 165 in go/host/l1/blockrepository.go

View workflow job for this annotation

GitHub Actions / lint

File is not `goimports`-ed (goimports)
continue
}

txData, err := r.createTransactionData(l.TxHash)
if err != nil {
r.logger.Error("Error creating transaction data", "txHash", l.TxHash, "error", err)
continue
}

// first topic is always the event signature
switch l.Topics[0] {
case crosschain.CrossChainEventID:
r.processCrossChainLogs(l, txData, processed)
Expand Down Expand Up @@ -323,19 +329,6 @@ func (r *Repository) FetchBlockByHeight(height *big.Int) (*types.Block, error) {
return r.ethClient.BlockByNumber(height)
}

// isObscuroTransaction will look at the 'to' address of the transaction, we are only interested in management contract and bridge transactions
func (r *Repository) isObscuroTransaction(transaction *types.Transaction) bool {
var allAddresses []gethcommon.Address
allAddresses = append(allAddresses, r.contractAddresses[MgmtContract]...)
allAddresses = append(allAddresses, r.contractAddresses[MsgBus]...)
for _, address := range allAddresses {
if transaction.To() != nil && *transaction.To() == address {
return true
}
}
return false
}

// getEnclaveIdFromLog gets the enclave ID from the log topic
func getEnclaveIdFromLog(log types.Log) (gethcommon.Address, error) {
if len(log.Topics) != 1 {
Expand Down
3 changes: 3 additions & 0 deletions integration/ethereummock/mgmt_contract_lib.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ func (m *mockContractLib) GetContractAddr() *gethcommon.Address {
func (m *mockContractLib) DecodeTx(tx *types.Transaction) ethadapter.L1Transaction {
// Do not decode erc20 transactions, this is the responsibility
// of the erc20 contract lib.
if tx.To() == nil {
println("HERE")
}
if tx.To().Hex() == depositTxAddr.Hex() {
return nil
}
Expand Down
2 changes: 0 additions & 2 deletions integration/simulation/simulation_in_mem_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ import (
// Everything else is reported to this value. This number has to be adjusted in conjunction with the number of nodes. If it's too low,
// the CPU usage will be very high during the simulation which might give inconclusive results.
func TestInMemoryMonteCarloSimulation(t *testing.T) {
//FIXME temporarily disable
t.Skipf("skipping test until mocks are written")
setupSimTestLog("in-mem")

// todo (#718) - try increasing this back to 7 once faster-finality model is optimised
Expand Down

0 comments on commit 7b7fd7a

Please sign in to comment.