diff --git a/prover/db/db.go b/prover/db/db.go deleted file mode 100644 index a86ae9ae0..000000000 --- a/prover/db/db.go +++ /dev/null @@ -1,52 +0,0 @@ -package db - -import ( - "bytes" - "math/big" - "strconv" - - "github.com/ethereum/go-ethereum/common" -) - -var ( - blockKeyPrefix = "block" - separator = "++" -) - -// SignedBlockData is the data stored in the db for a signed block -type SignedBlockData struct { - BlockID *big.Int - BlockHash common.Hash - Signature string -} - -// BuildBlockKey will build a block key for a signed block -func BuildBlockKey(blockTimestamp uint64, blockNumber uint64) []byte { - return bytes.Join( - [][]byte{ - []byte(blockKeyPrefix), - []byte(strconv.Itoa(int(blockTimestamp))), - []byte(strconv.Itoa(int(blockNumber))), - }, []byte(separator)) -} - -// BuildBlockValue will build a block value for a signed block -func BuildBlockValue(hash []byte, signature []byte, blockID *big.Int) []byte { - return bytes.Join( - [][]byte{ - hash, - signature, - blockID.Bytes(), - }, []byte(separator)) -} - -// SignedBlockDataFromValue will build a SignedBlockData from a value -func SignedBlockDataFromValue(val []byte) SignedBlockData { - v := bytes.Split(val, []byte(separator)) - - return SignedBlockData{ - BlockID: new(big.Int).SetBytes(v[2]), - BlockHash: common.BytesToHash(v[0]), - Signature: common.Bytes2Hex(v[1]), - } -} diff --git a/prover/db/db_test.go b/prover/db/db_test.go deleted file mode 100644 index edbf0b98f..000000000 --- a/prover/db/db_test.go +++ /dev/null @@ -1,35 +0,0 @@ -package db - -import ( - "bytes" - "math/big" - "testing" - - "github.com/ethereum/go-ethereum/common" - "github.com/stretchr/testify/assert" -) - -func Test_BuildBlockKey(t *testing.T) { - assert.Equal(t, []byte("block++1++300"), BuildBlockKey(1, 300)) -} - -func Test_BuildBlockValue(t *testing.T) { - v := BuildBlockValue([]byte("hash"), []byte("sig"), big.NewInt(1)) - spl := bytes.Split(v, []byte(separator)) - assert.Equal(t, "hash", string(spl[0])) - assert.Equal(t, "sig", string(spl[1])) - assert.Equal(t, uint64(1), new(big.Int).SetBytes(spl[2]).Uint64()) -} - -func Test_SignedBlockDataFromValue(t *testing.T) { - hash := common.HexToHash("1ada5c5ba58cfca1fbcd4531f4132f8cfef736c2cf40209a1315c489717dfc49") - // nolint: lll - sig := common.Hex2Bytes("789a80053e4927d0a898db8e065e948f5cf086e32f9ccaa54c1908e22ac430c62621578113ddbb62d509bf6049b8fb544ab06d36f916685a2eb8e57ffadde02301") - - v := BuildBlockValue(hash.Bytes(), sig, big.NewInt(1)) - data := SignedBlockDataFromValue(v) - - assert.Equal(t, common.Bytes2Hex(sig), data.Signature) - assert.Equal(t, hash, data.BlockHash) - assert.Equal(t, data.BlockID, big.NewInt(1)) -} diff --git a/prover/guardian_prover_heartbeater/guardian_prover.go b/prover/guardian_prover_heartbeater/guardian_prover.go index 111379c15..fb66fbcbb 100644 --- a/prover/guardian_prover_heartbeater/guardian_prover.go +++ b/prover/guardian_prover_heartbeater/guardian_prover.go @@ -226,11 +226,6 @@ func (s *GuardianProverHeartBeater) signBlock(ctx context.Context, blockID *big. return signed, header, nil } -// Close closes the underlying database. -func (s *GuardianProverHeartBeater) Close() error { - return nil -} - // SendHeartbeat sends a heartbeat to the health check server. func (s *GuardianProverHeartBeater) SendHeartbeat( ctx context.Context, diff --git a/prover/guardian_prover_heartbeater/interface.go b/prover/guardian_prover_heartbeater/interface.go index 95232a74b..1c0939c1e 100644 --- a/prover/guardian_prover_heartbeater/interface.go +++ b/prover/guardian_prover_heartbeater/interface.go @@ -27,5 +27,4 @@ type Heartbeater interface { type BlockSenderHeartbeater interface { BlockSigner Heartbeater - Close() error } diff --git a/prover/prover.go b/prover/prover.go index bcad2fac5..38a74c99e 100644 --- a/prover/prover.go +++ b/prover/prover.go @@ -321,12 +321,6 @@ func (p *Prover) eventLoop() { // Close closes the prover instance. func (p *Prover) Close(ctx context.Context) { - if p.guardianProverHeartbeater != nil { - if err := p.guardianProverHeartbeater.Close(); err != nil { - log.Error("failed to close database connection", "error", err) - } - } - if err := p.server.Shutdown(ctx); err != nil { log.Error("Failed to shut down prover server", "error", err) }