@@ -70,7 +70,6 @@ export default function makeBlockManager({
70
70
71
71
let currentActions = [ ] ;
72
72
let decohered ;
73
- let saveTime = 0 ;
74
73
75
74
async function blockManager ( action ) {
76
75
if ( decohered ) {
@@ -85,17 +84,6 @@ export default function makeBlockManager({
85
84
`Committed height ${ action . blockHeight } does not match computed height ${ computedHeight } ` ,
86
85
) ;
87
86
}
88
-
89
- const start = Date . now ( ) ;
90
-
91
- // Save the kernel's computed state because we've committed
92
- // the block (i.e. have obtained consensus on the prior
93
- // state).
94
- saveOutsideState ( computedHeight , savedActions ) ;
95
- savedHeight = computedHeight ;
96
-
97
- saveTime = Date . now ( ) - start ;
98
- currentActions = [ ] ;
99
87
break ;
100
88
}
101
89
@@ -138,8 +126,8 @@ export default function makeBlockManager({
138
126
if ( computedHeight === action . blockHeight ) {
139
127
// We are reevaluating, so send exactly the same downcalls to the chain.
140
128
//
141
- // This is necessary since the block proposer will be asked to validate
142
- // the actions it just proposed (in Tendermint v0.33.0) .
129
+ // This is necessary only after a restart when Tendermint is reevaluating the
130
+ // block that was interrupted and not committed .
143
131
//
144
132
// We assert that the return values are identical, which allows us not
145
133
// to resave our state.
@@ -165,17 +153,24 @@ export default function makeBlockManager({
165
153
const start = Date . now ( ) ;
166
154
const { mailboxSize } = saveChainState ( ) ;
167
155
const mbTime = Date . now ( ) - start ;
168
- log . debug (
169
- `wrote SwingSet checkpoint (mailbox=${ mailboxSize } ), [run=${ runTime } ms, mb=${ mbTime } ms, save=${ saveTime } ms]` ,
170
- ) ;
171
156
172
157
// Advance our saved state variables.
173
158
savedActions = currentActions ;
174
159
computedHeight = action . blockHeight ;
175
- if ( action . blockHeight === 0 ) {
176
- // No replay, no errors on genesis init.
177
- currentActions = [ ] ;
178
- }
160
+
161
+ // Save the kernel's computed state so that we can recover if we ever
162
+ // reset before Cosmos SDK commit.
163
+ const start2 = Date . now ( ) ;
164
+ saveOutsideState ( computedHeight , savedActions ) ;
165
+ savedHeight = computedHeight ;
166
+
167
+ const saveTime = Date . now ( ) - start2 ;
168
+
169
+ log . debug (
170
+ `wrote SwingSet checkpoint (mailbox=${ mailboxSize } ), [run=${ runTime } ms, mb=${ mbTime } ms, save=${ saveTime } ms]` ,
171
+ ) ;
172
+ currentActions = [ ] ;
173
+
179
174
break ;
180
175
}
181
176
0 commit comments