diff --git a/model/actors/common/actors.go b/model/actors/common/actors.go index fd836c8bb..ba5d2b58c 100644 --- a/model/actors/common/actors.go +++ b/model/actors/common/actors.go @@ -79,6 +79,8 @@ type ActorState struct { Code string `pg:",pk,notnull"` // Top level of state data as json. State string `pg:",type:jsonb,notnull"` + // The next Actor nonce that is expected to appear on chain. + Nonce uint64 `pg:",use_zero"` } func (as *ActorState) Persist(ctx context.Context, s model.StorageBatch, version model.Version) error { diff --git a/schemas/v1/13_actorstates_nonce.go b/schemas/v1/13_actorstates_nonce.go new file mode 100644 index 000000000..caa7de885 --- /dev/null +++ b/schemas/v1/13_actorstates_nonce.go @@ -0,0 +1,14 @@ +package v1 + +func init() { + patches.Register( + 13, + ` +ALTER TABLE {{ .SchemaName | default "public"}}.actor_states + ADD COLUMN nonce BIGINT, + ADD CONSTRAINT actor_states_uniq_nullable_nonce UNIQUE (height,head,nonce); + +COMMENT ON COLUMN {{ .SchemaName | default "public"}}.actor_states.nonce IS 'The nonce of the actor expected to appear on the chain after the actor has been modified or created at each epoch. More precisely, this nonce tracks the number of messages sent by an actor.'; +`, + ) +} diff --git a/tasks/actorstate/raw/actor_state.go b/tasks/actorstate/raw/actor_state.go index c599f8759..21a9509f3 100644 --- a/tasks/actorstate/raw/actor_state.go +++ b/tasks/actorstate/raw/actor_state.go @@ -43,5 +43,6 @@ func (RawActorStateExtractor) Extract(ctx context.Context, a actorstate.ActorInf Head: a.Actor.Head.String(), Code: a.Actor.Code.String(), State: string(state), + Nonce: a.Actor.Nonce, }, nil }