@@ -34,8 +34,8 @@ const (
3434var (
3535 _adminKey = []byte ("adm" )
3636 _fundKey = []byte ("fnd" )
37- _blockRewardHistoryKeyPrefix = [] byte ( "brh" )
38- _epochRewardHistoryKeyPrefix = [] byte ( "erh" )
37+ _blockRewardHistoryKeyPrefix = state . BlockRewardHistoryKeyPrefix
38+ _epochRewardHistoryKeyPrefix = state . EpochRewardHistoryKeyPrefix
3939 _accountKeyPrefix = []byte ("acc" )
4040 _exemptKey = []byte ("xpt" )
4141 errInvalidEpoch = errors .New ("invalid start/end epoch number" )
@@ -61,7 +61,7 @@ func NewProtocol(cfg genesis.Rewarding) *Protocol {
6161 log .L ().Panic ("failed to validate foundation bonus extension" , zap .Error (err ))
6262 }
6363 return & Protocol {
64- keyPrefix : h [:],
64+ keyPrefix : state . RewardingKeyPrefix [:],
6565 addr : addr ,
6666 cfg : cfg ,
6767 }
@@ -331,8 +331,9 @@ func (p *Protocol) stateCheckLegacy(ctx context.Context, sm protocol.StateReader
331331}
332332
333333func (p * Protocol ) stateV1 (sm protocol.StateReader , key []byte , value interface {}) (uint64 , error ) {
334- keyHash := hash .Hash160b (append (p .keyPrefix , key ... ))
335- return sm .State (value , protocol .LegacyKeyOption (keyHash ))
334+ orgKey := append (p .keyPrefix , key ... )
335+ keyHash := hash .Hash160b (orgKey )
336+ return sm .State (value , protocol .LegacyKeyOption (keyHash ), protocol .ErigonStoreKeyOption (orgKey ))
336337}
337338
338339func (p * Protocol ) stateV2 (sm protocol.StateReader , key []byte , value interface {}) (uint64 , error ) {
@@ -348,8 +349,9 @@ func (p *Protocol) putState(ctx context.Context, sm protocol.StateManager, key [
348349}
349350
350351func (p * Protocol ) putStateV1 (sm protocol.StateManager , key []byte , value interface {}) error {
351- keyHash := hash .Hash160b (append (p .keyPrefix , key ... ))
352- _ , err := sm .PutState (value , protocol .LegacyKeyOption (keyHash ))
352+ orgKey := append (p .keyPrefix , key ... )
353+ keyHash := hash .Hash160b (orgKey )
354+ _ , err := sm .PutState (value , protocol .LegacyKeyOption (keyHash ), protocol .ErigonStoreKeyOption (orgKey ))
353355 return err
354356}
355357
@@ -360,8 +362,9 @@ func (p *Protocol) putStateV2(sm protocol.StateManager, key []byte, value interf
360362}
361363
362364func (p * Protocol ) deleteStateV1 (sm protocol.StateManager , key []byte , obj any ) error {
363- keyHash := hash .Hash160b (append (p .keyPrefix , key ... ))
364- _ , err := sm .DelState (protocol .LegacyKeyOption (keyHash ), protocol .ObjectOption (obj ))
365+ orgKey := append (p .keyPrefix , key ... )
366+ keyHash := hash .Hash160b (orgKey )
367+ _ , err := sm .DelState (protocol .LegacyKeyOption (keyHash ), protocol .ObjectOption (obj ), protocol .ErigonStoreKeyOption (orgKey ))
365368 if errors .Cause (err ) == state .ErrStateNotExist {
366369 // don't care if not exist
367370 return nil
0 commit comments