Skip to content
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
17 changes: 7 additions & 10 deletions internal/test/ledger/ledger.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,20 +63,17 @@ func (ls MockLedgerState) StakeRegistration(
return ret, nil
}

func (ls MockLedgerState) PoolRegistration(
func (ls MockLedgerState) PoolCurrentState(
poolKeyHash []byte,
) ([]common.PoolRegistrationCertificate, error) {
ret := []common.PoolRegistrationCertificate{}
) (*common.PoolRegistrationCertificate, *uint64, error) {
for _, cert := range ls.MockPoolRegistration {
if string(
common.Blake2b224(cert.Operator).Bytes(),
) == string(
poolKeyHash,
) {
ret = append(ret, cert)
if string(common.Blake2b224(cert.Operator).Bytes()) == string(poolKeyHash) {
// pretend latest registration is current; no retirement support in mock
c := cert
return &c, nil, nil
}
}
return ret, nil
return nil, nil, nil
}

func (ls MockLedgerState) SlotToTime(slot uint64) (time.Time, error) {
Expand Down
4 changes: 2 additions & 2 deletions ledger/alonzo/rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,11 +289,11 @@ func UtxoValidateValueNotConservedUtxo(
for _, cert := range tx.Certificates() {
switch tmpCert := cert.(type) {
case *common.PoolRegistrationCertificate:
certs, err := ls.PoolRegistration(common.Blake2b224(tmpCert.Operator).Bytes())
reg, _, err := ls.PoolCurrentState(common.Blake2b224(tmpCert.Operator).Bytes())
if err != nil {
return err
}
if len(certs) == 0 {
if reg == nil {
producedValue += uint64(tmpPparams.PoolDeposit)
}
case *common.StakeRegistrationCertificate:
Expand Down
4 changes: 2 additions & 2 deletions ledger/babbage/rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,11 +275,11 @@ func UtxoValidateValueNotConservedUtxo(
for _, cert := range tx.Certificates() {
switch tmpCert := cert.(type) {
case *common.PoolRegistrationCertificate:
certs, err := ls.PoolRegistration(common.Blake2b224(tmpCert.Operator).Bytes())
reg, _, err := ls.PoolCurrentState(common.Blake2b224(tmpCert.Operator).Bytes())
if err != nil {
return err
}
if len(certs) == 0 {
if reg == nil {
producedValue += uint64(tmpPparams.PoolDeposit)
}
case *common.StakeRegistrationCertificate:
Expand Down
10 changes: 9 additions & 1 deletion ledger/common/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,22 @@ type UtxoState interface {
// CertState defines the interface for querying the certificate state
type CertState interface {
StakeRegistration([]byte) ([]StakeRegistrationCertificate, error)
PoolRegistration([]byte) ([]PoolRegistrationCertificate, error)
}

// PoolState defines the interface for querying the current pool state
type PoolState interface {
// PoolCurrentState returns the latest active registration certificate for the given pool key hash.
// It also returns the epoch of a pending retirement certificate, if one exists.
// If the pool is not registered, the registration certificate will be nil.
PoolCurrentState([]byte) (*PoolRegistrationCertificate, *uint64, error)
}

// LedgerState defines the interface for querying the ledger
type LedgerState interface {
UtxoState
CertState
SlotState
PoolState
NetworkId() uint
}

Expand Down
4 changes: 2 additions & 2 deletions ledger/conway/rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,11 +272,11 @@ func UtxoValidateValueNotConservedUtxo(
for _, cert := range tx.Certificates() {
switch tmpCert := cert.(type) {
case *common.PoolRegistrationCertificate:
certs, err := ls.PoolRegistration(common.Blake2b224(tmpCert.Operator).Bytes())
reg, _, err := ls.PoolCurrentState(common.Blake2b224(tmpCert.Operator).Bytes())
if err != nil {
return err
}
if len(certs) == 0 {
if reg == nil {
producedValue += uint64(tmpPparams.PoolDeposit)
}
case *common.RegistrationCertificate:
Expand Down
4 changes: 2 additions & 2 deletions ledger/shelley/rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,11 +196,11 @@ func UtxoValidateValueNotConservedUtxo(
for _, cert := range tx.Certificates() {
switch tmpCert := cert.(type) {
case *common.PoolRegistrationCertificate:
certs, err := ls.PoolRegistration(common.Blake2b224(tmpCert.Operator).Bytes())
reg, _, err := ls.PoolCurrentState(common.Blake2b224(tmpCert.Operator).Bytes())
if err != nil {
return err
}
if len(certs) == 0 {
if reg == nil {
producedValue += uint64(tmpPparams.PoolDeposit)
}
case *common.StakeRegistrationCertificate:
Expand Down
Loading