From 02eb26ec3593eb755aee9fec6d6219365326ad7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Kripalani?= Date: Sun, 12 Feb 2023 16:37:23 +0000 Subject: [PATCH] fix signature backwards compatibility. --- chain/signatures.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/chain/signatures.go b/chain/signatures.go index 1701482f2..268a8e14f 100644 --- a/chain/signatures.go +++ b/chain/signatures.go @@ -23,7 +23,7 @@ func AuthenticateMessage(msg *types.SignedMessage, signer address.Address, nv ne typ := msg.Signature.Type switch typ { case crypto.SigTypeDelegated: - if msg.Message.Method == builtin.MethodSend && nv >= network.Version20 { + if nv >= network.Version20 && msg.Message.Method == builtin.MethodSend { return xerrors.Errorf("nv20 and above no longer admits method 0 on messages with Ethereum delegated signatures") } txArgs, err := ethtypes.EthTxArgsFromUnsignedEthMessage(&msg.Message) @@ -35,6 +35,12 @@ func AuthenticateMessage(msg *types.SignedMessage, signer address.Address, nv ne return xerrors.Errorf("failed to reconstruct filecoin msg: %w", err) } + // Prior to nv20, delegated signature messages with no parameters carried MethodSend. + // Reset the value so we'll roundtrip. + if nv < network.Version20 && roundTripMsg.Method == builtin.MethodsEVM.InvokeContract && len(roundTripMsg.Params) == 0 { + roundTripMsg.Method = builtin.MethodSend + } + if !msg.Message.Equals(roundTripMsg) { return xerrors.New("ethereum tx failed to roundtrip") }