diff --git a/services/datacom/datacom.go b/services/datacom/datacom.go index 871e17a2..dea1315c 100644 --- a/services/datacom/datacom.go +++ b/services/datacom/datacom.go @@ -40,9 +40,11 @@ func (d *Endpoints) SignSequence(signedSequence types.SignedSequence) (interface if err != nil { return "0x0", rpc.NewRPCError(rpc.DefaultErrorCode, "failed to verify sender") } + if sender != d.sequencerTracker.GetAddr() { return "0x0", rpc.NewRPCError(rpc.DefaultErrorCode, "unauthorized") } + // Store off-chain data by hash (hash(L2Data): L2Data) _, err = d.txMan.NewDbTxScope(d.db, func(ctx context.Context, dbTx db.Tx) (interface{}, rpc.Error) { err := d.db.StoreOffChainData(ctx, signedSequence.Sequence.OffChainData(), dbTx) @@ -55,11 +57,12 @@ func (d *Endpoints) SignSequence(signedSequence types.SignedSequence) (interface if err != nil { return "0x0", rpc.NewRPCError(rpc.DefaultErrorCode, err.Error()) } + // Sign signedSequenceByMe, err := signedSequence.Sequence.Sign(d.privateKey) if err != nil { return "0x0", rpc.NewRPCError(rpc.DefaultErrorCode, fmt.Errorf("failed to sign. Error: %w", err).Error()) } - // Return signature + return signedSequenceByMe.Signature, nil } diff --git a/services/sync/sync.go b/services/sync/sync.go index 11eae652..e855729b 100644 --- a/services/sync/sync.go +++ b/services/sync/sync.go @@ -10,8 +10,13 @@ import ( "github.com/ethereum/go-ethereum/common" ) -// APISYNC is the namespace of the sync service -const APISYNC = "sync" +const ( + // APISYNC is the namespace of the sync service + APISYNC = "sync" + + // maxListHashes is the maximum number of hashes that can be requested in a ListOffChainData call + maxListHashes = 100 +) // Endpoints contains implementations for the "zkevm" RPC endpoints type Endpoints struct { @@ -41,6 +46,11 @@ func (z *Endpoints) GetOffChainData(hash types.ArgHash) (interface{}, rpc.Error) // ListOffChainData returns the list of images of the given hashes func (z *Endpoints) ListOffChainData(hashes []types.ArgHash) (interface{}, rpc.Error) { + if len(hashes) > maxListHashes { + log.Errorf("too many hashes requested in ListOffChainData: %d", len(hashes)) + return "0x0", rpc.NewRPCError(rpc.InvalidRequestErrorCode, "too many hashes requested") + } + keys := make([]common.Hash, len(hashes)) for i, hash := range hashes { keys[i] = hash.Hash()