Skip to content

Commit

Permalink
Merge branch 'refs/heads/master' into masih/f3-cli-list-power-table
Browse files Browse the repository at this point in the history
# Conflicts:
#	CHANGELOG.md
  • Loading branch information
masih committed Nov 19, 2024
2 parents cb52aa9 + 1f5f51f commit a91ba96
Show file tree
Hide file tree
Showing 10 changed files with 86 additions and 46 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

# UNRELEASED

## Bug Fixes

- Make `EthTraceFilter` / `trace_filter` skip null rounds instead of erroring. ([filecoin-project/lotus#12702](https://github.com/filecoin-project/lotus/pull/12702))

## New Features

* Implement F3 utility CLIs to list the power table for a given instance and sum the proportional power of a set of actors that participate in a given instance. See: https://github.com/filecoin-project/lotus/pull/12698.
Expand Down
2 changes: 1 addition & 1 deletion chain/lf3/participation.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ func (p *Participant) tryParticipate(ctx context.Context, ticket api.F3Participa
log.Debugw("Reattempting F3 participation with the same ticket.", "attempts", p.backoff.Attempt())
continue
case errors.Is(err, api.ErrF3NotReady):
log.Warnw("F3 is not ready. Retrying F3 participation after backoff.", "backoff", p.backoff.Duration(), "err", err)
log.Debugw("F3 is not ready. Retrying F3 participation after backoff.", "backoff", p.backoff.Duration(), "err", err)
p.backOff(ctx)
continue
case err != nil:
Expand Down
5 changes: 5 additions & 0 deletions documentation/en/default-lotus-config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@
[Fevm]
# EnableEthRPC enables eth_ RPC methods.
# Note: Setting this to true will also require that ChainIndexer is enabled, otherwise it will cause an error at startup.
# Set EnableIndexer in the ChainIndexer section of the config to true to enable the ChainIndexer.
#
# type: bool
# env var: LOTUS_FEVM_ENABLEETHRPC
Expand All @@ -249,6 +250,7 @@
# EnableActorEventsAPI enables the Actor events API that enables clients to consume events
# emitted by (smart contracts + built-in Actors).
# Note: Setting this to true will also require that ChainIndexer is enabled, otherwise it will cause an error at startup.
# Set EnableIndexer in the ChainIndexer section of the config to true to enable the ChainIndexer.
#
# type: bool
# env var: LOTUS_EVENTS_ENABLEACTOREVENTSAPI
Expand Down Expand Up @@ -294,6 +296,9 @@
#
# Setting this to true will enable the indexer, which will significantly improve RPC performance.
# It is strongly recommended to keep this set to true if you are an RPC provider.
#
# If EnableEthRPC or EnableActorEventsAPI are set to true, the ChainIndexer must be enabled using
# this option to avoid errors at startup.
#
# type: bool
# env var: LOTUS_CHAININDEXER_ENABLEINDEXER
Expand Down
66 changes: 30 additions & 36 deletions itests/eth_api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
inittypes "github.com/filecoin-project/go-state-types/builtin/v8/init"
"github.com/filecoin-project/go-state-types/exitcode"

"github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/lotus/build/buildconstants"
"github.com/filecoin-project/lotus/chain/actors/policy"
"github.com/filecoin-project/lotus/chain/types"
Expand Down Expand Up @@ -401,43 +400,38 @@ func TestEthBlockNumberAliases(t *testing.T) {
ens.InterconnectAll().BeginMining(blockTime)
ens.Start()

build.Clock.Sleep(time.Second)

ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
defer cancel()

head := client.WaitTillChain(ctx, kit.HeightAtLeast(policy.ChainFinality+100))
// latest should be head-1 (parents)
var latestEthBlk ethtypes.EthBlock
for {
var err error
latestEthBlk, err = client.EVM().EthGetBlockByNumber(ctx, "latest", true)
require.NoError(t, err)
afterHead, err := client.ChainHead(ctx)
require.NoError(t, err)
if afterHead.Height() == head.Height() {
break
}
// else: whoops, we had a chain increment between getting head and getting "latest" so they're
// clearly not going to match, try again
head = afterHead
client.WaitTillChain(ctx, kit.HeightAtLeast(policy.ChainFinality+100))

for _, tc := range []struct {
param string
expectedLag abi.ChainEpoch
}{
{"latest", 1}, // head - 1
{"safe", 30 + 1}, // "latest" - 30
{"finalized", policy.ChainFinality + 1}, // "latest" - 900
} {
t.Run(tc.param, func(t *testing.T) {
head, err := client.ChainHead(ctx)
require.NoError(t, err)
var blk ethtypes.EthBlock
for { // get a block while retaining a stable "head" reference
blk, err = client.EVM().EthGetBlockByNumber(ctx, tc.param, true)
require.NoError(t, err)
afterHead, err := client.ChainHead(ctx)
require.NoError(t, err)
if afterHead.Height() == head.Height() {
break
}
// else: whoops, we had a chain increment between getting head and getting "latest" so
// we won't be able to use head as a stable reference for comparison
head = afterHead
}
ts, err := client.ChainGetTipSetByHeight(ctx, head.Height()-tc.expectedLag, head.Key())
require.NoError(t, err)
require.EqualValues(t, ts.Height(), blk.Number)
})
}

diff := int64(latestEthBlk.Number) - int64(head.Height()-1)
require.GreaterOrEqual(t, diff, int64(0))
require.LessOrEqual(t, diff, int64(2))

// safe should be latest-30
safeEthBlk, err := client.EVM().EthGetBlockByNumber(ctx, "safe", true)
require.NoError(t, err)
diff = int64(latestEthBlk.Number-30) - int64(safeEthBlk.Number)
require.GreaterOrEqual(t, diff, int64(0))
require.LessOrEqual(t, diff, int64(2))

// finalized should be Finality blocks behind latest
finalityEthBlk, err := client.EVM().EthGetBlockByNumber(ctx, "finalized", true)
require.NoError(t, err)
diff = int64(latestEthBlk.Number) - int64(policy.ChainFinality) - int64(finalityEthBlk.Number)
require.GreaterOrEqual(t, diff, int64(0))
require.LessOrEqual(t, diff, int64(2))
}
30 changes: 27 additions & 3 deletions itests/eth_transactions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,7 @@ func TestTraceFilter(t *testing.T) {
blockTime := 100 * time.Millisecond
client, _, ens := kit.EnsembleMinimal(t, kit.MockProofs(), kit.ThroughRPC())

ens.InterconnectAll().BeginMining(blockTime)
bms := ens.InterconnectAll().BeginMining(blockTime)

ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
defer cancel()
Expand Down Expand Up @@ -844,7 +844,7 @@ func TestTraceFilter(t *testing.T) {
require.NotNil(t, tracesAddressFilter)
require.NotEmpty(t, tracesAddressFilter)

//we should only get our contract deploy transaction
// we should only get our contract deploy transaction
require.Len(t, tracesAddressFilter, 1)
require.Equal(t, 1, tracesAddressFilter[0].TransactionPosition)
require.Equal(t, hash, tracesAddressFilter[0].TransactionHash)
Expand All @@ -864,8 +864,32 @@ func TestTraceFilter(t *testing.T) {
require.NotNil(t, traces)
require.NotEmpty(t, traces)

//we should only get the last two results from the first trace query
// we should only get the last two results from the first trace query
require.Len(t, tracesAfterCount, 2)
require.Equal(t, traces[1].TransactionHash, tracesAfterCount[0].TransactionHash)
require.Equal(t, traces[2].TransactionHash, tracesAfterCount[1].TransactionHash)

// make sure we have null rounds in the chain
bms[0].InjectNulls(2)
ch, err := client.ChainNotify(ctx)
require.NoError(t, err)
hc := <-ch // current
require.Equal(t, store.HCCurrent, hc[0].Type)
beforeNullHeight := hc[0].Val.Height()
hc = <-ch // wait for next block
require.Equal(t, store.HCApply, hc[0].Type)
afterNullHeight := hc[0].Val.Height()
require.Greater(t, afterNullHeight, beforeNullHeight+1)
hc = <-ch // one more, so "latest" points to the block after nulls
require.Equal(t, store.HCApply, hc[0].Type)

// define filter criteria that spans a null round so it has to at lest consider it
toBlock = "latest"
filter = ethtypes.EthTraceFilterCriteria{
FromBlock: &fromBlock,
ToBlock: &toBlock,
}
traces, err = client.EthTraceFilter(ctx, filter)
require.NoError(t, err)
require.Len(t, traces, 3) // still the same traces as before
}
4 changes: 2 additions & 2 deletions node/builder_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,10 @@ func ConfigFullNode(c interface{}) Option {
}

if cfg.Fevm.EnableEthRPC && !cfg.ChainIndexer.EnableIndexer {
return Error(xerrors.New("chain indexer must be enabled if ETH RPC is enabled"))
return Error(xerrors.New("EnableIndexer in the ChainIndexer configuration section must be set to true when setting EnableEthRPC to true"))
}
if cfg.Events.EnableActorEventsAPI && !cfg.ChainIndexer.EnableIndexer {
return Error(xerrors.New("chain indexer must be enabled if actor events API is enabled"))
return Error(xerrors.New("EnableIndexer in the ChainIndexer configuration section must be set to true when setting EnableActorEventsAPI to true"))
}

return Options(
Expand Down
11 changes: 8 additions & 3 deletions node/config/doc_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions node/config/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,7 @@ type FeeConfig struct {
type FevmConfig struct {
// EnableEthRPC enables eth_ RPC methods.
// Note: Setting this to true will also require that ChainIndexer is enabled, otherwise it will cause an error at startup.
// Set EnableIndexer in the ChainIndexer section of the config to true to enable the ChainIndexer.
EnableEthRPC bool

// EthTraceFilterMaxResults sets the maximum results returned per request by trace_filter
Expand All @@ -557,6 +558,7 @@ type EventsConfig struct {
// EnableActorEventsAPI enables the Actor events API that enables clients to consume events
// emitted by (smart contracts + built-in Actors).
// Note: Setting this to true will also require that ChainIndexer is enabled, otherwise it will cause an error at startup.
// Set EnableIndexer in the ChainIndexer section of the config to true to enable the ChainIndexer.
EnableActorEventsAPI bool

// FilterTTL specifies the time to live for actor event filters. Filters that haven't been accessed longer than
Expand Down Expand Up @@ -587,6 +589,9 @@ type ChainIndexerConfig struct {
//
// Setting this to true will enable the indexer, which will significantly improve RPC performance.
// It is strongly recommended to keep this set to true if you are an RPC provider.
//
// If EnableEthRPC or EnableActorEventsAPI are set to true, the ChainIndexer must be enabled using
// this option to avoid errors at startup.
EnableIndexer bool

// GCRetentionEpochs specifies the number of epochs for which data is retained in the Indexer.
Expand Down
3 changes: 3 additions & 0 deletions node/impl/full/eth.go
Original file line number Diff line number Diff line change
Expand Up @@ -1364,6 +1364,9 @@ func (a *EthModule) EthTraceFilter(ctx context.Context, filter ethtypes.EthTrace
for blkNum := fromBlock; blkNum <= toBlock; blkNum++ {
blockTraces, err := a.EthTraceBlock(ctx, strconv.FormatUint(uint64(blkNum), 10))
if err != nil {
if errors.Is(err, &api.ErrNullRound{}) {
continue
}
return nil, xerrors.Errorf("cannot get trace for block %d: %w", blkNum, err)
}

Expand Down
2 changes: 1 addition & 1 deletion storage/sealer/storiface/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ type StorageInfo struct {
// storage path
MaxStorage uint64

// CanStore is true when the path is allowed to be used for io-intensive
// CanSeal is true when the path is allowed to be used for io-intensive
// sealing operations
CanSeal bool

Expand Down

0 comments on commit a91ba96

Please sign in to comment.