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

filter out irrelevant l1 txs, before sending into the enclave #2006

Merged
merged 1 commit into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
Changes from all 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 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
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the only material change in this pr

// 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