forked from cerc-io/ipld-eth-server
(VDB-68) Verify log block hash matches header block hash
- Delete header on conflict to prompt data refresh (cascade deletes all data associated with that block) - Derive header hash from rpc payload rather than computing it from data (prevents hash mismatch between blockchain and cache)
This commit is contained in:
@@ -26,7 +26,7 @@ type VatFluxRepository struct {
|
||||
db *postgres.DB
|
||||
}
|
||||
|
||||
func (repository VatFluxRepository) Create(headerId int64, models []interface{}) error {
|
||||
func (repository VatFluxRepository) Create(headerID int64, models []interface{}) error {
|
||||
tx, err := repository.db.Begin()
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -39,16 +39,22 @@ func (repository VatFluxRepository) Create(headerId int64, models []interface{})
|
||||
return fmt.Errorf("model of type %T, not %T", model, VatFluxModel{})
|
||||
}
|
||||
|
||||
_, err := tx.Exec(`INSERT INTO maker.vat_flux (header_id, ilk, dst, src, rad, tx_idx, log_idx, raw_log)
|
||||
err = shared.ValidateHeaderConsistency(headerID, vatFlux.Raw, repository.db)
|
||||
if err != nil {
|
||||
tx.Rollback()
|
||||
return err
|
||||
}
|
||||
|
||||
_, err = tx.Exec(`INSERT INTO maker.vat_flux (header_id, ilk, dst, src, rad, tx_idx, log_idx, raw_log)
|
||||
VALUES($1, $2, $3, $4, $5::NUMERIC, $6, $7, $8)`,
|
||||
headerId, vatFlux.Ilk, vatFlux.Dst, vatFlux.Src, vatFlux.Rad, vatFlux.TransactionIndex, vatFlux.LogIndex, vatFlux.Raw)
|
||||
headerID, vatFlux.Ilk, vatFlux.Dst, vatFlux.Src, vatFlux.Rad, vatFlux.TransactionIndex, vatFlux.LogIndex, vatFlux.Raw)
|
||||
if err != nil {
|
||||
tx.Rollback()
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
err = shared.MarkHeaderCheckedInTransaction(headerId, tx, constants.VatFluxChecked)
|
||||
err = shared.MarkHeaderCheckedInTransaction(headerID, tx, constants.VatFluxChecked)
|
||||
if err != nil {
|
||||
tx.Rollback()
|
||||
return err
|
||||
|
||||
@@ -21,11 +21,11 @@ import (
|
||||
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres/repositories"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/fakes"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data/shared_behaviors"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/vat_flux"
|
||||
"github.com/vulcanize/vulcanizedb/test_config"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants"
|
||||
)
|
||||
|
||||
var _ = Describe("VatFlux Repository", func() {
|
||||
|
||||
Reference in New Issue
Block a user