Skip to content

Commit

Permalink
fixed new state transition
Browse files Browse the repository at this point in the history
  • Loading branch information
olegfomenko committed Aug 16, 2023
1 parent 976f53d commit 43824af
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
10 changes: 10 additions & 0 deletions internal/rarimo/stateupdate.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ func (m *StateUpdateMessageMaker) StateUpdateMsgByBlock(ctx context.Context, iss
return nil, err
}

if latestState == nil || replacedState == nil {
return nil, nil
}

length, err := m.stateDataProvider.GetGISTRootHistoryLength(&bind.CallOpts{
Context: ctx,
})
Expand Down Expand Up @@ -132,6 +136,12 @@ func (m *StateUpdateMessageMaker) getStatesOnBlock(ctx context.Context, issuer,
return nil, nil, errors.Wrap(err, "failed to get overall states count")
}

if length.Cmp(big.NewInt(1)) == 0 {
// It is a new state. Only one state transition exist. Ignore that state transition.
// FIXME
return nil, nil, nil
}

for {
states, err := m.stateDataProvider.GetStateInfoHistoryById(&bind.CallOpts{
Context: ctx,
Expand Down
5 changes: 5 additions & 0 deletions internal/services/evm/stateChangeListener.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,11 @@ func (l *stateChangeListener) subscription(ctx context.Context) error {
continue
}

if msg == nil {
l.log.WithField("tx_hash", e.Raw.TxHash.String()).Info("ignoring that state transition")
continue
}

if err := l.broadcaster.BroadcastTx(ctx, msg); err != nil {
l.log.WithError(err).WithField("tx_hash", e.Raw.TxHash.String()).Error(err, "failed to broadcast state updated msg")
continue
Expand Down

0 comments on commit 43824af

Please sign in to comment.