Skip to content

Commit

Permalink
filter out irrelevant l1 txs, before sending into the enclave
Browse files Browse the repository at this point in the history
  • Loading branch information
tudor-malene committed Aug 2, 2024
1 parent 7b62b2e commit 9a70a54
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion go/common/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ type (
// To work properly, all of the receipts are required, due to rlp encoding pruning some of the information.
// The receipts must also be in the correct order.
type BlockAndReceipts struct {
Block *types.Block
Block *L1Block
ReceiptsMap map[int]*types.Receipt // sparse map with obscuro-relevant receipts in it
Receipts *types.Receipts
successfulTransactions *types.Transactions
Expand Down
3 changes: 1 addition & 2 deletions go/enclave/nodetype/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package nodetype
import (
"context"

"github.com/ethereum/go-ethereum/core/types"
"github.com/ten-protocol/go-ten/go/common"
"github.com/ten-protocol/go-ten/go/enclave/components"
"github.com/ten-protocol/go-ten/go/enclave/core"
Expand All @@ -21,7 +20,7 @@ type NodeType interface {
OnL1Fork(ctx context.Context, fork *common.ChainFork) error

// OnL1Block - performed after the block was processed
OnL1Block(ctx context.Context, block *types.Block, result *components.BlockIngestionType) error
OnL1Block(ctx context.Context, block *common.L1Block, result *components.BlockIngestionType) error

ExportCrossChainData(context.Context, uint64, uint64) (*common.ExtCrossChainBundle, error)

Expand Down
2 changes: 1 addition & 1 deletion go/enclave/nodetype/sequencer.go
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ func (s *sequencer) signCrossChainBundle(bundle *common.ExtCrossChainBundle) err
return nil
}

func (s *sequencer) OnL1Block(ctx context.Context, block *types.Block, result *components.BlockIngestionType) error {
func (s *sequencer) OnL1Block(ctx context.Context, _ *common.L1Block, result *components.BlockIngestionType) error {
// nothing to do
return nil
}
Expand Down
4 changes: 1 addition & 3 deletions go/enclave/nodetype/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import (
"github.com/ten-protocol/go-ten/go/enclave/crypto"
"github.com/ten-protocol/go-ten/go/enclave/txpool"

"github.com/ethereum/go-ethereum/core/types"

"github.com/ten-protocol/go-ten/go/common/errutil"
"github.com/ten-protocol/go-ten/go/common/log"
"github.com/ten-protocol/go-ten/go/common/signature"
Expand Down Expand Up @@ -187,7 +185,7 @@ func (val *obsValidator) handleGenesis(ctx context.Context, batch *common.BatchH
return nil
}

func (val *obsValidator) OnL1Block(ctx context.Context, block *types.Block, result *components.BlockIngestionType) error {
func (val *obsValidator) OnL1Block(ctx context.Context, _ *common.L1Block, result *components.BlockIngestionType) error {
return val.ExecuteStoredBatches(ctx)
}

Expand Down
9 changes: 9 additions & 0 deletions go/host/enclave/guardian.go
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,15 @@ func (g *Guardian) submitL1Block(block *common.L1Block, isLatest bool) (bool, er
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)
}
// only submit the relevant transactions to the enclave
// nullify all non-relevant transactions
txs := block.Transactions()
for i, rec := range receipts {
if rec == nil {
txs[i] = nil
}
}

resp, err := g.enclaveClient.SubmitL1Block(context.Background(), block, receipts, isLatest)
g.submitDataLock.Unlock() // lock is only guarding the enclave call, so we can release it now
if err != nil {
Expand Down

0 comments on commit 9a70a54

Please sign in to comment.