fix: eth: use the correct state-tree when resolving addresses (#11387)
We need to always use the state-tree from the tipset _after_ the message executed. If we use any other state-tree, we might not find the address we're trying to resolve. This change also has some implication for pending messages: there's no guarantee we'll be able to generate a 0x-style address for a pending native message. So, instead of trying, I've removed support for pending native messages from the Eth API. Messages from EthAccounts will still work, and native messages will still show up in blocks/traces, they just won't show up as "pending". Which should affect exactly nobody. I'm also taking this opportunity to cleanup some edge-cases: 1. Pass contexts where appropriate. 2. Remove all state access from `ethTxHashFromSignedMessage`. Part of #11355
This commit is contained in:
1 parent
06d288e92b
commit
9b4df6a4d0
8 files changed
+133
-69
No files matched your search
@@ -120,7 +120,6 @@ func TestTransactionHashLookupBlsFilecoinMessage(t *testing.T) {
|
||||
kit.MockProofs(),
|
||||
kit.ThroughRPC(),
|
||||
)
|
||||
ens.InterconnectAll().BeginMining(blocktime)
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
|
||||
defer cancel()
|
||||
@@ -146,9 +145,13 @@ func TestTransactionHashLookupBlsFilecoinMessage(t *testing.T) {
|
||||
hash, err := ethtypes.EthHashFromCid(sm.Message.Cid())
|
||||
require.NoError(t, err)
|
||||
|
||||
mpoolTx, err := client.EthGetTransactionByHash(ctx, &hash)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, hash, mpoolTx.Hash)
|
||||
// Assert that BLS messages cannot be retrieved from the message pool until it lands
|
||||
// on-chain via the eth API.
|
||||
_, err = client.EthGetTransactionByHash(ctx, &hash)
|
||||
require.Error(t, err)
|
||||
|
||||
// Now start mining.
|
||||
ens.InterconnectAll().BeginMining(blocktime)
|
||||
|
||||
// Wait for message to land on chain
|
||||
var receipt *api.EthTxReceipt
|
||||
@@ -177,6 +180,13 @@ func TestTransactionHashLookupBlsFilecoinMessage(t *testing.T) {
|
||||
require.NotEmpty(t, *chainTx.BlockHash)
|
||||
require.NotNil(t, chainTx.TransactionIndex)
|
||||
require.Equal(t, uint64(*chainTx.TransactionIndex), uint64(0)) // only transaction
|
||||
|
||||
// verify that we correctly reported the to address.
|
||||
toId, err := client.StateLookupID(ctx, addr, types.EmptyTSK)
|
||||
require.NoError(t, err)
|
||||
toEth, err := client.FilecoinAddressToEthAddress(ctx, toId)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, &toEth, chainTx.To)
|
||||
}
|
||||
|
||||
// TestTransactionHashLookupSecpFilecoinMessage tests to see if lotus can find a Secp Filecoin Message using the transaction hash
|
||||
@@ -228,10 +238,6 @@ func TestTransactionHashLookupSecpFilecoinMessage(t *testing.T) {
|
||||
hash, err := ethtypes.EthHashFromCid(secpSmsg.Cid())
|
||||
require.NoError(t, err)
|
||||
|
||||
mpoolTx, err := client.EthGetTransactionByHash(ctx, &hash)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, hash, mpoolTx.Hash)
|
||||
|
||||
_, err = client.StateWaitMsg(ctx, secpSmsg.Cid(), 3, api.LookbackNoLimit, true)
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -253,6 +259,13 @@ func TestTransactionHashLookupSecpFilecoinMessage(t *testing.T) {
|
||||
require.NotEmpty(t, *chainTx.BlockHash)
|
||||
require.NotNil(t, chainTx.TransactionIndex)
|
||||
require.Equal(t, uint64(*chainTx.TransactionIndex), uint64(0)) // only transaction
|
||||
|
||||
// verify that we correctly reported the to address.
|
||||
toId, err := client.StateLookupID(ctx, client.DefaultKey.Address, types.EmptyTSK)
|
||||
require.NoError(t, err)
|
||||
toEth, err := client.FilecoinAddressToEthAddress(ctx, toId)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, &toEth, chainTx.To)
|
||||
}
|
||||
|
||||
// TestTransactionHashLookupSecpFilecoinMessage tests to see if lotus can find a Secp Filecoin Message using the transaction hash
|
||||
|
||||
Reference in new issue
Block a user