Fix panic in EthGetCode

This commit is contained in:
Ian Davis
2023-01-26 12:10:42 +00:00
parent a9cd76907e
commit 7586710395
2 changed files with 113 additions and 102 deletions
+5 -1
View File
@@ -441,6 +441,11 @@ func (a *EthModule) EthGetCode(ctx context.Context, ethAddr ethtypes.EthAddress,
return nil, xerrors.Errorf("cannot parse block param: %s", blkParam)
}
// StateManager.Call will panic if there is no parent
if ts.Height() == 0 {
return nil, xerrors.Errorf("block param must not specify genesis block")
}
// Try calling until we find a height with no migration.
var res *api.InvocResult
for {
@@ -838,7 +843,6 @@ func (a *EthModule) EthCall(ctx context.Context, tx ethtypes.EthCall, blkParam s
if msg.To == builtintypes.EthereumAddressManagerActorAddr {
// As far as I can tell, the Eth API always returns empty on contract deployment
return ethtypes.EthBytes{}, nil
} else if len(invokeResult.MsgRct.Return) > 0 {
return cbg.ReadByteArray(bytes.NewReader(invokeResult.MsgRct.Return), uint64(len(invokeResult.MsgRct.Return)))
}