diff --git a/go/enclave/components/rollup_consumer.go b/go/enclave/components/rollup_consumer.go index c75c8444d..5ce9d529c 100644 --- a/go/enclave/components/rollup_consumer.go +++ b/go/enclave/components/rollup_consumer.go @@ -27,7 +27,7 @@ type rollupConsumerImpl struct { logger gethlog.Logger storage storage.Storage - sigValidator *SignatureValidator + sigValidator SequencerSignatureVerifier } func NewRollupConsumer( @@ -36,7 +36,7 @@ func NewRollupConsumer( rollupCompression *RollupCompression, storage storage.Storage, logger gethlog.Logger, - verifier *SignatureValidator, + verifier SequencerSignatureVerifier, ) RollupConsumer { return &rollupConsumerImpl{ MgmtContractLib: mgmtContractLib, diff --git a/go/enclave/components/sigverifier.go b/go/enclave/components/sigverifier.go index 5a85b2064..dc441fea4 100644 --- a/go/enclave/components/sigverifier.go +++ b/go/enclave/components/sigverifier.go @@ -12,13 +12,17 @@ import ( gethcommon "github.com/ethereum/go-ethereum/common" ) +// SequencerSignatureVerifier interface for signature validation +type SequencerSignatureVerifier interface { + CheckSequencerSignature(hash gethcommon.Hash, sig []byte) error +} + type SignatureValidator struct { attestedKey *ecdsa.PublicKey storage storage.Storage } func NewSignatureValidator(storage storage.Storage) (*SignatureValidator, error) { - // todo (#718) - sequencer identities should be retrieved from the L1 management contract return &SignatureValidator{ storage: storage, attestedKey: nil, @@ -36,11 +40,6 @@ func (sigChecker *SignatureValidator) CheckSequencerSignature(hash gethcommon.Ha return fmt.Errorf("could not fetch sequencer IDs: %w", err) } - // todo no-op for in-mem test, we can add a mock version of this - if len(sequencerIDs) == 0 { - return nil - } - // loop through sequencer keys and exit early if one of them matches for _, seqID := range sequencerIDs { attestedEnclave, err := sigChecker.storage.GetEnclavePubKey(context.Background(), seqID) diff --git a/go/enclave/enclave_admin_service.go b/go/enclave/enclave_admin_service.go index 7194c1869..d3c2c80e0 100644 --- a/go/enclave/enclave_admin_service.go +++ b/go/enclave/enclave_admin_service.go @@ -4,6 +4,7 @@ import ( "context" "errors" "fmt" + "github.com/ten-protocol/go-ten/integration/ethereummock" "math/big" "sync" "time" @@ -68,11 +69,10 @@ func NewEnclaveAdminAPI(config *enclaveconfig.EnclaveConfig, storage storage.Sto } } sharedSecretProcessor := components.NewSharedSecretProcessor(mgmtContractLib, attestationProvider, enclaveKeyService.EnclaveID(), storage, sharedSecretService, logger) - sigVerifier, err := components.NewSignatureValidator(storage) + sigVerifier, err := getSignatureValidator(config.UseInMemoryDB, storage) if err != nil { logger.Crit("Could not initialise the signature validator", log.ErrKey, err) } - dataCompressionService := compression.NewBrotliDataCompressionService() rollupCompression := components.NewRollupCompression(registry, batchExecutor, daEncryptionService, dataCompressionService, storage, gethEncodingService, chainConfig, config, logger) @@ -600,3 +600,10 @@ func exportCrossChainData(ctx context.Context, storage storage.Storage, fromSeqN } // todo: check fromSeqNo return bundle, nil } + +func getSignatureValidator(useInMemDB bool, storage storage.Storage) (components.SequencerSignatureVerifier, error) { + if useInMemDB { + return ethereummock.NewMockSignatureValidator(), nil + } + return components.NewSignatureValidator(storage) +} diff --git a/go/enclave/nodetype/validator.go b/go/enclave/nodetype/validator.go index 7383542b4..4a9939a9a 100644 --- a/go/enclave/nodetype/validator.go +++ b/go/enclave/nodetype/validator.go @@ -27,7 +27,7 @@ type validator struct { chainConfig *params.ChainConfig storage storage.Storage - sigValidator *components.SignatureValidator + sigValidator components.SequencerSignatureVerifier mempool *components.TxPool logger gethlog.Logger @@ -39,7 +39,7 @@ func NewValidator( registry components.BatchRegistry, chainConfig *params.ChainConfig, storage storage.Storage, - sigValidator *components.SignatureValidator, + sigValidator components.SequencerSignatureVerifier, mempool *components.TxPool, logger gethlog.Logger, ) Validator { diff --git a/integration/ethereummock/mock_sigverifier.go b/integration/ethereummock/mock_sigverifier.go new file mode 100644 index 000000000..f485fb3a7 --- /dev/null +++ b/integration/ethereummock/mock_sigverifier.go @@ -0,0 +1,16 @@ +package ethereummock + +import ( + gethcommon "github.com/ethereum/go-ethereum/common" +) + +type MockSignatureValidator struct{} + +func NewMockSignatureValidator() *MockSignatureValidator { + return &MockSignatureValidator{} +} + +// CheckSequencerSignature - NO-OP +func (sigChecker *MockSignatureValidator) CheckSequencerSignature(_ gethcommon.Hash, _ []byte) error { + return nil +}