Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: review fevm #5659

Merged
merged 8 commits into from
Jan 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 12 additions & 14 deletions app/submodule/chain/chaininfo_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -559,19 +559,17 @@ func (cia *chainInfoAPI) StateWaitMsg(ctx context.Context, mCid cid.Cid, confide
recpt := msgResult.Receipt
if recpt.ExitCode == 0 && len(recpt.Return) > 0 {
vmsg := chainMsg.VMMessage()
t, err := cia.getReturnType(ctx, vmsg.To, vmsg.Method)
if err != nil {
if errors.Is(err, ErrMetadataNotFound) {
// This is not nececessary an error -- EVM methods (and in the future native actors) may
// return just bytes, and in the not so distant future we'll have native wasm actors
// that are by definition not in the registry.
// So in this case, log a debug message and retun the raw bytes.
log.Debugf("failed to get return type: %s", err)
returndec = recpt.Return
} else {
return nil, fmt.Errorf("failed to get return type: %w", err)
}
} else {
switch t, err := cia.getReturnType(ctx, vmsg.To, vmsg.Method); {
case errors.Is(err, ErrMetadataNotFound):
// This is not necessarily an error -- EVM methods (and in the future native actors) may
// return just bytes, and in the not so distant future we'll have native wasm actors
// that are by definition not in the registry.
// So in this case, log a debug message and retun the raw bytes.
log.Debugf("failed to get return type: %s", err)
returndec = recpt.Return
case err != nil:
return nil, fmt.Errorf("failed to get return type: %w", err)
default:
if err := t.UnmarshalCBOR(bytes.NewReader(recpt.Return)); err != nil {
return nil, err
}
Expand Down Expand Up @@ -864,7 +862,7 @@ func (cia *chainInfoAPI) StateReplay(ctx context.Context, tsk types.TipSetKey, m
// ChainGetEvents returns the events under an event AMT root CID.
func (cia *chainInfoAPI) ChainGetEvents(ctx context.Context, root cid.Cid) ([]types.Event, error) {
store := cbor.NewCborStore(cia.chain.ChainReader.Blockstore())
evtArr, err := amt4.LoadAMT(ctx, store, root, amt4.UseTreeBitWidth(5))
evtArr, err := amt4.LoadAMT(ctx, store, root, amt4.UseTreeBitWidth(types.EventAMTBitwidth))
if err != nil {
return nil, fmt.Errorf("load events amt: %w", err)
}
Expand Down
19 changes: 6 additions & 13 deletions app/submodule/eth/eth_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"github.com/filecoin-project/venus/pkg/vm"
"github.com/filecoin-project/venus/pkg/vm/vmcontext"
"github.com/filecoin-project/venus/venus-shared/actors"
builtinactors "github.com/filecoin-project/venus/venus-shared/actors/builtin"
v1 "github.com/filecoin-project/venus/venus-shared/api/chain/v1"
"github.com/filecoin-project/venus/venus-shared/types"
"github.com/ipfs/go-cid"
Expand Down Expand Up @@ -559,17 +558,11 @@ func (a *ethAPI) EthSendRawTransaction(ctx context.Context, rawTx types.EthBytes
func (a *ethAPI) ethCallToFilecoinMessage(ctx context.Context, tx types.EthCall) (*types.Message, error) {
var from address.Address
if tx.From == nil || *tx.From == (types.EthAddress{}) {
// TODO: We're sending from the "burnt funds" account for now, because we need to
// send from an actual account till we deploy an EVM _account_ to this address, not
// an empty EVM contract.
//
// See https://github.com/filecoin-project/ref-fvm/issues/1173
from = builtinactors.BurntFundsActorAddr
// Send from the filecoin "system" address.
// from, err = (api.EthAddress{}).ToFilecoinAddress()
// if err != nil {
// return nil, fmt.Errorf("failed to construct the ethereum system address: %w", err)
// }
var err error
from, err = (types.EthAddress{}).ToFilecoinAddress()
if err != nil {
return nil, fmt.Errorf("failed to construct the ethereum system address: %w", err)
}
} else {
// The from address must be translatable to an f4 address.
var err error
Expand Down Expand Up @@ -771,7 +764,7 @@ func newEthBlockFromFilecoinTipSet(ctx context.Context, ts *types.TipSet, fullTx
// Filecoin address. It does the following:
//
// 1. If the supplied address is an f410 address, we return its payload as the EthAddress.
// 2. Otherwise (f0, f1, f2, f3), we look up the actor on the state tree. If it has a predictable address, we return it if it's f410 address.
// 2. Otherwise (f0, f1, f2, f3), we look up the actor on the state tree. If it has a delegated address, we return it if it's f410 address.
// 3. Otherwise, we fall back to returning a masked ID Ethereum address. If the supplied address is an f0 address, we
// use that ID to form the masked ID address.
// 4. Otherwise, we fetch the actor's ID from the state tree and form the masked ID with it.
Expand Down
3 changes: 2 additions & 1 deletion app/submodule/mining/mining_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ func (miningAPI *MiningAPI) minerCreateBlock(ctx context.Context, bt *types.Bloc

var blsMsgCids, secpkMsgCids []cid.Cid
var blsSigs []crypto.Signature
nv := miningAPI.Ming.ChainModule.Fork.GetNetworkVersion(ctx, bt.Epoch)
for _, msg := range bt.Messages {
if msg.Signature.Type == crypto.SigTypeBLS {
blsSigs = append(blsSigs, msg.Signature)
Expand All @@ -220,7 +221,7 @@ func (miningAPI *MiningAPI) minerCreateBlock(ctx context.Context, bt *types.Bloc
}

blsMsgCids = append(blsMsgCids, c)
} else if msg.Signature.Type == crypto.SigTypeSecp256k1 || msg.Signature.Type == crypto.SigTypeDelegated {
} else if chain.IsValidSecpkSigType(nv, msg.Signature.Type) {
c, err := messageStore.StoreMessage(msg)
if err != nil {
return nil, err
Expand Down
Loading