From 2bbd1fbbb610645650bc439abb2984f8c38ded61 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Mon, 13 Feb 2023 10:59:20 -0800 Subject: [PATCH 1/4] fix: stmgr: check message validity before invoking vm Otherwise we may, e.g., try to estimate gas on a message to an f4 address before the nv18 migration. I'm _not_ checking the "prior messages" here as this is just a sanity check. --- chain/stmgr/call.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/chain/stmgr/call.go b/chain/stmgr/call.go index ea2758705..e6b742255 100644 --- a/chain/stmgr/call.go +++ b/chain/stmgr/call.go @@ -107,6 +107,14 @@ func (sm *StateManager) callInternal(ctx context.Context, msg *types.Message, pr } } + // This isn't strictly necessary, but the underlying VM will assume that the message is + // valid and may not return helpful debugging information. Checking here makes message + // validity issues easier to debug. + nv := sm.GetNetworkVersion(ctx, ts.Height()) + if err := msg.ValidForBlockInclusion(0, nv); err != nil { + return nil, xerrors.Errorf("message not valid for network version %d: %w", nv, err) + } + // Unless executing on a specific state cid, apply all the messages from the current tipset // first. Unfortunately, we can't just execute the tipset, because that will run cron. We // don't want to apply miner messages after cron runs in a given epoch. From 9f2f9154d2fa77303f91d4444d0c61fdf3ccefd1 Mon Sep 17 00:00:00 2001 From: snissn Date: Mon, 13 Feb 2023 19:29:11 -0700 Subject: [PATCH 2/4] itest for block.difficulty (#10263) --- itests/contracts/GetDifficulty.hex | 1 + itests/contracts/GetDifficulty.sol | 9 +++++++++ itests/fevm_test.go | 13 +++++++++++++ 3 files changed, 23 insertions(+) create mode 100644 itests/contracts/GetDifficulty.hex create mode 100644 itests/contracts/GetDifficulty.sol diff --git a/itests/contracts/GetDifficulty.hex b/itests/contracts/GetDifficulty.hex new file mode 100644 index 000000000..6d584b233 --- /dev/null +++ b/itests/contracts/GetDifficulty.hex @@ -0,0 +1 @@ +608060405234801561001057600080fd5b5060b58061001f6000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c8063b6baffe314602d575b600080fd5b60336047565b604051603e91906066565b60405180910390f35b600044905090565b6000819050919050565b606081604f565b82525050565b6000602082019050607960008301846059565b9291505056fea2646970667358221220c113f1abaabaed6a0324d363896b0d15a8bca7b9a540948a5be5b636a12a534f64736f6c63430008110033 \ No newline at end of file diff --git a/itests/contracts/GetDifficulty.sol b/itests/contracts/GetDifficulty.sol new file mode 100644 index 000000000..155e7cfd1 --- /dev/null +++ b/itests/contracts/GetDifficulty.sol @@ -0,0 +1,9 @@ +// SPDX-License-Identifier: MIT +pragma solidity >=0.8.17; + +contract GetDifficulty { + function getDifficulty () public view returns (uint256) { + return block.difficulty; + } +} + diff --git a/itests/fevm_test.go b/itests/fevm_test.go index 074f66f12..3018bf63d 100644 --- a/itests/fevm_test.go +++ b/itests/fevm_test.go @@ -855,3 +855,16 @@ func TestFEVMProxyUpgradeable(t *testing.T) { _, _, err := client.EVM().InvokeContractByFuncName(ctx, fromAddr, contractAddr, "test()", []byte{}) require.NoError(t, err) } + +func TestFEVMGetBlockDifficulty(t *testing.T) { + ctx, cancel, client := kit.SetupFEVMTest(t) + defer cancel() + + //install contract + filenameActor := "contracts/GetDifficulty.hex" + fromAddr, contractAddr := client.EVM().DeployContractFromFilename(ctx, filenameActor) + + ret, _, err := client.EVM().InvokeContractByFuncName(ctx, fromAddr, contractAddr, "getDifficulty()", []byte{}) + require.NoError(t, err) + require.Equal(t, len(ret), 32) +} From 2ed92c222d79557702e15e0bde96b9a03e7beddb Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Mon, 13 Feb 2023 18:42:29 -0800 Subject: [PATCH 3/4] chore: ffi: update the FFI This: - Improves error handling when the FFI is passed invalid messages. - Updates the FVM. --- extern/filecoin-ffi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extern/filecoin-ffi b/extern/filecoin-ffi index 4c503e5e2..7efaa7b47 160000 --- a/extern/filecoin-ffi +++ b/extern/filecoin-ffi @@ -1 +1 @@ -Subproject commit 4c503e5e2291b5d541f89d982d975e7994536a54 +Subproject commit 7efaa7b47fe9d4bdb4ba0b2a0fafa4e573864ee5 From abeb4fadc4dd34cda4d781d1831bbf4860005c63 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Mon, 13 Feb 2023 18:42:44 -0800 Subject: [PATCH 4/4] fix: itest: EthFeeHistory flake (#10265) --- itests/eth_fee_history_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/itests/eth_fee_history_test.go b/itests/eth_fee_history_test.go index 33b4c8ae3..72302f298 100644 --- a/itests/eth_fee_history_test.go +++ b/itests/eth_fee_history_test.go @@ -28,7 +28,7 @@ func TestEthFeeHistory(t *testing.T) { defer cancel() // Wait for the network to create 20 blocks - <-time.After(20 * blockTime) + client.WaitTillChain(ctx, kit.HeightAtLeast(20)) history, err := client.EthFeeHistory(ctx, result.Wrap[jsonrpc.RawParams]( json.Marshal([]interface{}{5, "0x10"}),