@@ -23,7 +23,6 @@ import (
2323 "github.com/ava-labs/avalanchego/snow/choices"
2424 "github.com/ava-labs/avalanchego/snow/consensus/snowman"
2525 "github.com/ava-labs/avalanchego/snow/engine/common"
26- "github.com/ava-labs/avalanchego/utils/hashing"
2726 "github.com/ava-labs/avalanchego/utils/wrappers"
2827 "github.com/ava-labs/avalanchego/vms/components/missing"
2928 "github.com/ava-labs/avalanchego/vms/rpcchainvm/galiaslookup"
@@ -298,8 +297,10 @@ func (vm *VMClient) BuildBlock() (snowman.Block, error) {
298297
299298 id , err := ids .ToID (resp .Id )
300299 vm .ctx .Log .AssertNoError (err )
300+
301301 parentID , err := ids .ToID (resp .ParentID )
302302 vm .ctx .Log .AssertNoError (err )
303+
303304 vm .missingBlocks .Evict (id )
304305
305306 return & BlockClient {
@@ -314,17 +315,6 @@ func (vm *VMClient) BuildBlock() (snowman.Block, error) {
314315
315316// ParseBlock ...
316317func (vm * VMClient ) ParseBlock (bytes []byte ) (snowman.Block , error ) {
317- blkID := hashing .ComputeHash256Array (bytes )
318-
319- if blk , cached := vm .blks [blkID ]; cached {
320- return blk , nil
321- }
322- if blkIntf , cached := vm .decidedBlocks .Get (blkID ); cached {
323- return blkIntf .(* BlockClient ), nil
324- }
325-
326- vm .missingBlocks .Evict (blkID )
327-
328318 resp , err := vm .client .ParseBlock (context .Background (), & vmproto.ParseBlockRequest {
329319 Bytes : bytes ,
330320 })
@@ -334,10 +324,18 @@ func (vm *VMClient) ParseBlock(bytes []byte) (snowman.Block, error) {
334324
335325 id , err := ids .ToID (resp .Id )
336326 vm .ctx .Log .AssertNoError (err )
337- vm .ctx .Log .AssertTrue (id != blkID , "Unexpected blockID returned from plugin" )
327+
328+ if blk , cached := vm .blks [id ]; cached {
329+ return blk , nil
330+ }
331+ if blkIntf , cached := vm .decidedBlocks .Get (id ); cached {
332+ return blkIntf .(* BlockClient ), nil
333+ }
334+ vm .missingBlocks .Evict (id )
338335
339336 parentID , err := ids .ToID (resp .ParentID )
340337 vm .ctx .Log .AssertNoError (err )
338+
341339 status := choices .Status (resp .Status )
342340 vm .ctx .Log .AssertDeferredNoError (status .Valid )
343341
0 commit comments