From 709cb2b1097844075eb8d9ab956b6a70dbd8cd77 Mon Sep 17 00:00:00 2001 From: "Andrew Jackson (Ajax)" Date: Wed, 24 Sep 2025 16:59:57 -0500 Subject: [PATCH 01/11] xss fix --- api/proxy_gen.go | 206 +++++++++++++----- cuhttp/server.go | 4 +- deps/config/doc_gen.go | 7 +- deps/config/types.go | 7 +- .../default-curio-configuration.md | 7 +- .../en/curio-market/curio-http-server.md | 4 +- web/srv.go | 23 +- 7 files changed, 179 insertions(+), 79 deletions(-) diff --git a/api/proxy_gen.go b/api/proxy_gen.go index 114481675..7737717e1 100644 --- a/api/proxy_gen.go +++ b/api/proxy_gen.go @@ -4,16 +4,8 @@ package api import ( "context" - "net/http" - "net/url" - "reflect" - - "github.com/google/uuid" - blocks "github.com/ipfs/go-block-format" - "github.com/ipfs/go-cid" - "github.com/multiformats/go-multihash" - "golang.org/x/xerrors" - + ltypes "github.com/filecoin-project/curio/api/types" + "github.com/filecoin-project/curio/lib/storiface" "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-bitfield" "github.com/filecoin-project/go-jsonrpc/auth" @@ -23,219 +15,328 @@ import ( "github.com/filecoin-project/go-state-types/crypto" "github.com/filecoin-project/go-state-types/dline" "github.com/filecoin-project/go-state-types/network" - - ltypes "github.com/filecoin-project/curio/api/types" - "github.com/filecoin-project/curio/lib/storiface" - "github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/chain/actors/builtin/miner" "github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/node/modules/dtypes" lpiece "github.com/filecoin-project/lotus/storage/pipeline/piece" "github.com/filecoin-project/lotus/storage/sealer/fsutil" + "github.com/google/uuid" + blocks "github.com/ipfs/go-block-format" + "github.com/ipfs/go-cid" + "github.com/multiformats/go-multihash" + "net/http" + "net/url" + "reflect" + + "golang.org/x/xerrors" ) + var _ = reflect.TypeOf([]byte(nil)) var ErrNotSupported = xerrors.New("method not supported") + type CurioStruct struct { + Internal CurioMethods } type CurioMethods struct { + AllocatePieceToSector func(p0 context.Context, p1 address.Address, p2 lpiece.PieceDealInfo, p3 int64, p4 url.URL, p5 http.Header) (api.SectorOffset, error) `perm:"write"` - Cordon func(p0 context.Context) error `perm:"admin"` + + Cordon func(p0 context.Context) (error) `perm:"admin"` + IndexSamples func(p0 context.Context, p1 cid.Cid) ([]multihash.Multihash, error) `perm:"admin"` + Info func(p0 context.Context) (*ltypes.NodeInfo, error) `perm:"read"` + LogList func(p0 context.Context) ([]string, error) `perm:"read"` - LogSetLevel func(p0 context.Context, p1 string, p2 string) error `perm:"admin"` - Shutdown func(p0 context.Context) error `perm:"admin"` + LogSetLevel func(p0 context.Context, p1 string, p2 string) (error) `perm:"admin"` + + + Shutdown func(p0 context.Context) (error) `perm:"admin"` - StorageAddLocal func(p0 context.Context, p1 string) error `perm:"admin"` - StorageDetachLocal func(p0 context.Context, p1 string) error `perm:"admin"` + StorageAddLocal func(p0 context.Context, p1 string) (error) `perm:"admin"` + + + StorageDetachLocal func(p0 context.Context, p1 string) (error) `perm:"admin"` + StorageFindSector func(p0 context.Context, p1 abi.SectorID, p2 storiface.SectorFileType, p3 abi.SectorSize, p4 bool) ([]storiface.SectorStorageInfo, error) `perm:"admin"` + StorageGenerateVanillaProof func(p0 context.Context, p1 address.Address, p2 abi.SectorNumber) ([]byte, error) `perm:"admin"` + StorageInfo func(p0 context.Context, p1 storiface.ID) (storiface.StorageInfo, error) `perm:"admin"` - StorageInit func(p0 context.Context, p1 string, p2 storiface.LocalStorageMeta) error `perm:"admin"` + + StorageInit func(p0 context.Context, p1 string, p2 storiface.LocalStorageMeta) (error) `perm:"admin"` + StorageList func(p0 context.Context) (map[storiface.ID][]storiface.Decl, error) `perm:"admin"` + StorageLocal func(p0 context.Context) (map[storiface.ID]string, error) `perm:"admin"` - StorageRedeclare func(p0 context.Context, p1 *storiface.ID, p2 bool) error `perm:"admin"` + + StorageRedeclare func(p0 context.Context, p1 *storiface.ID, p2 bool) (error) `perm:"admin"` + StorageStat func(p0 context.Context, p1 storiface.ID) (fsutil.FsStat, error) `perm:"admin"` - Uncordon func(p0 context.Context) error `perm:"admin"` + + Uncordon func(p0 context.Context) (error) `perm:"admin"` + Version func(p0 context.Context) ([]int, error) `perm:"admin"` -} + + + } type CurioStub struct { + } type CurioChainRPCStruct struct { + Internal CurioChainRPCMethods } type CurioChainRPCMethods struct { + AuthNew func(p0 context.Context, p1 []auth.Permission) ([]byte, error) `perm:"admin"` + AuthVerify func(p0 context.Context, p1 string) ([]auth.Permission, error) `perm:"read"` + ChainGetMessage func(p0 context.Context, p1 cid.Cid) (*types.Message, error) `` + ChainGetTipSet func(p0 context.Context, p1 types.TipSetKey) (*types.TipSet, error) `` + ChainGetTipSetAfterHeight func(p0 context.Context, p1 abi.ChainEpoch, p2 types.TipSetKey) (*types.TipSet, error) `` + ChainGetTipSetByHeight func(p0 context.Context, p1 abi.ChainEpoch, p2 types.TipSetKey) (*types.TipSet, error) `` + ChainHasObj func(p0 context.Context, p1 cid.Cid) (bool, error) `` + ChainHead func(p0 context.Context) (*types.TipSet, error) `` + ChainNotify func(p0 context.Context) (<-chan []*api.HeadChange, error) `` - ChainPutObj func(p0 context.Context, p1 blocks.Block) error `` + + ChainPutObj func(p0 context.Context, p1 blocks.Block) (error) `` + ChainReadObj func(p0 context.Context, p1 cid.Cid) ([]byte, error) `` + ChainTipSetWeight func(p0 context.Context, p1 types.TipSetKey) (types.BigInt, error) `` + GasEstimateFeeCap func(p0 context.Context, p1 *types.Message, p2 int64, p3 types.TipSetKey) (types.BigInt, error) `` + GasEstimateGasPremium func(p0 context.Context, p1 uint64, p2 address.Address, p3 int64, p4 types.TipSetKey) (types.BigInt, error) `` + GasEstimateMessageGas func(p0 context.Context, p1 *types.Message, p2 *api.MessageSendSpec, p3 types.TipSetKey) (*types.Message, error) `` + MarketAddBalance func(p0 context.Context, p1 address.Address, p2 address.Address, p3 types.BigInt) (cid.Cid, error) `` + MinerCreateBlock func(p0 context.Context, p1 *api.BlockTemplate) (*types.BlockMsg, error) `` + MinerGetBaseInfo func(p0 context.Context, p1 address.Address, p2 abi.ChainEpoch, p3 types.TipSetKey) (*api.MiningBaseInfo, error) `` + MpoolGetNonce func(p0 context.Context, p1 address.Address) (uint64, error) `` + MpoolPush func(p0 context.Context, p1 *types.SignedMessage) (cid.Cid, error) `` + MpoolPushMessage func(p0 context.Context, p1 *types.Message, p2 *api.MessageSendSpec) (*types.SignedMessage, error) `` + MpoolSelect func(p0 context.Context, p1 types.TipSetKey, p2 float64) ([]*types.SignedMessage, error) `` + Session func(p0 context.Context) (uuid.UUID, error) `perm:"read"` - Shutdown func(p0 context.Context) error `perm:"admin"` + + Shutdown func(p0 context.Context) (error) `perm:"admin"` + StateAccountKey func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (address.Address, error) `` + StateCall func(p0 context.Context, p1 *types.Message, p2 types.TipSetKey) (*api.InvocResult, error) `` + StateCirculatingSupply func(p0 context.Context, p1 types.TipSetKey) (big.Int, error) `` + StateDealProviderCollateralBounds func(p0 context.Context, p1 abi.PaddedPieceSize, p2 bool, p3 types.TipSetKey) (api.DealCollateralBounds, error) `` + StateGetActor func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (*types.Actor, error) `` + StateGetAllocation func(p0 context.Context, p1 address.Address, p2 verifregtypes.AllocationId, p3 types.TipSetKey) (*verifregtypes.Allocation, error) `` + StateGetAllocationForPendingDeal func(p0 context.Context, p1 abi.DealID, p2 types.TipSetKey) (*verifregtypes.Allocation, error) `` + StateGetAllocationIdForPendingDeal func(p0 context.Context, p1 abi.DealID, p2 types.TipSetKey) (verifregtypes.AllocationId, error) `` + StateGetBeaconEntry func(p0 context.Context, p1 abi.ChainEpoch) (*types.BeaconEntry, error) `` + StateGetRandomnessFromBeacon func(p0 context.Context, p1 crypto.DomainSeparationTag, p2 abi.ChainEpoch, p3 []byte, p4 types.TipSetKey) (abi.Randomness, error) `` + StateGetRandomnessFromTickets func(p0 context.Context, p1 crypto.DomainSeparationTag, p2 abi.ChainEpoch, p3 []byte, p4 types.TipSetKey) (abi.Randomness, error) `` + StateListMessages func(p0 context.Context, p1 *api.MessageMatch, p2 types.TipSetKey, p3 abi.ChainEpoch) ([]cid.Cid, error) `` + StateListMiners func(p0 context.Context, p1 types.TipSetKey) ([]address.Address, error) `` + StateLookupID func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (address.Address, error) `` + StateMarketBalance func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (api.MarketBalance, error) `` + StateMarketStorageDeal func(p0 context.Context, p1 abi.DealID, p2 types.TipSetKey) (*api.MarketDeal, error) `` + StateMinerActiveSectors func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) ([]*miner.SectorOnChainInfo, error) `` + StateMinerAllocated func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (*bitfield.BitField, error) `` + StateMinerAvailableBalance func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (types.BigInt, error) `perm:"read"` + StateMinerCreationDeposit func(p0 context.Context, p1 types.TipSetKey) (types.BigInt, error) `` + StateMinerDeadlines func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) ([]api.Deadline, error) `perm:"read"` + StateMinerFaults func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (bitfield.BitField, error) `` + StateMinerInfo func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (api.MinerInfo, error) `` + StateMinerInitialPledgeForSector func(p0 context.Context, p1 abi.ChainEpoch, p2 abi.SectorSize, p3 uint64, p4 types.TipSetKey) (types.BigInt, error) `` + StateMinerPartitions func(p0 context.Context, p1 address.Address, p2 uint64, p3 types.TipSetKey) ([]api.Partition, error) `` + StateMinerPower func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (*api.MinerPower, error) `perm:"read"` + StateMinerPreCommitDepositForPower func(p0 context.Context, p1 address.Address, p2 miner.SectorPreCommitInfo, p3 types.TipSetKey) (big.Int, error) `` + StateMinerProvingDeadline func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (*dline.Info, error) `` + StateMinerRecoveries func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (bitfield.BitField, error) `` + StateMinerSectorCount func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (api.MinerSectors, error) `` + StateMinerSectors func(p0 context.Context, p1 address.Address, p2 *bitfield.BitField, p3 types.TipSetKey) ([]*miner.SectorOnChainInfo, error) `` + StateNetworkName func(p0 context.Context) (dtypes.NetworkName, error) `` + StateNetworkVersion func(p0 context.Context, p1 types.TipSetKey) (network.Version, error) `` + StateReadState func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (*api.ActorState, error) `` + StateSearchMsg func(p0 context.Context, p1 types.TipSetKey, p2 cid.Cid, p3 abi.ChainEpoch, p4 bool) (*api.MsgLookup, error) `` + StateSectorGetInfo func(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (*miner.SectorOnChainInfo, error) `` + StateSectorPartition func(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (*miner.SectorLocation, error) `` + StateSectorPreCommitInfo func(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (*miner.SectorPreCommitOnChainInfo, error) `` + StateVMCirculatingSupplyInternal func(p0 context.Context, p1 types.TipSetKey) (api.CirculatingSupply, error) `` + StateVerifiedClientStatus func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (*abi.StoragePower, error) `` + StateWaitMsg func(p0 context.Context, p1 cid.Cid, p2 uint64, p3 abi.ChainEpoch, p4 bool) (*api.MsgLookup, error) `perm:"read"` - SyncSubmitBlock func(p0 context.Context, p1 *types.BlockMsg) error `` + + SyncSubmitBlock func(p0 context.Context, p1 *types.BlockMsg) (error) `` + Version func(p0 context.Context) (api.APIVersion, error) `perm:"read"` + WalletBalance func(p0 context.Context, p1 address.Address) (big.Int, error) `` + WalletHas func(p0 context.Context, p1 address.Address) (bool, error) `` + WalletSign func(p0 context.Context, p1 address.Address, p2 []byte) (*crypto.Signature, error) `` + WalletSignMessage func(p0 context.Context, p1 address.Address, p2 *types.Message) (*types.SignedMessage, error) `` -} + + + } type CurioChainRPCStub struct { + } + + + + func (s *CurioStruct) AllocatePieceToSector(p0 context.Context, p1 address.Address, p2 lpiece.PieceDealInfo, p3 int64, p4 url.URL, p5 http.Header) (api.SectorOffset, error) { if s.Internal.AllocatePieceToSector == nil { return *new(api.SectorOffset), ErrNotSupported @@ -247,14 +348,14 @@ func (s *CurioStub) AllocatePieceToSector(p0 context.Context, p1 address.Address return *new(api.SectorOffset), ErrNotSupported } -func (s *CurioStruct) Cordon(p0 context.Context) error { +func (s *CurioStruct) Cordon(p0 context.Context) (error) { if s.Internal.Cordon == nil { return ErrNotSupported } return s.Internal.Cordon(p0) } -func (s *CurioStub) Cordon(p0 context.Context) error { +func (s *CurioStub) Cordon(p0 context.Context) (error) { return ErrNotSupported } @@ -291,47 +392,47 @@ func (s *CurioStub) LogList(p0 context.Context) ([]string, error) { return *new([]string), ErrNotSupported } -func (s *CurioStruct) LogSetLevel(p0 context.Context, p1 string, p2 string) error { +func (s *CurioStruct) LogSetLevel(p0 context.Context, p1 string, p2 string) (error) { if s.Internal.LogSetLevel == nil { return ErrNotSupported } return s.Internal.LogSetLevel(p0, p1, p2) } -func (s *CurioStub) LogSetLevel(p0 context.Context, p1 string, p2 string) error { +func (s *CurioStub) LogSetLevel(p0 context.Context, p1 string, p2 string) (error) { return ErrNotSupported } -func (s *CurioStruct) Shutdown(p0 context.Context) error { +func (s *CurioStruct) Shutdown(p0 context.Context) (error) { if s.Internal.Shutdown == nil { return ErrNotSupported } return s.Internal.Shutdown(p0) } -func (s *CurioStub) Shutdown(p0 context.Context) error { +func (s *CurioStub) Shutdown(p0 context.Context) (error) { return ErrNotSupported } -func (s *CurioStruct) StorageAddLocal(p0 context.Context, p1 string) error { +func (s *CurioStruct) StorageAddLocal(p0 context.Context, p1 string) (error) { if s.Internal.StorageAddLocal == nil { return ErrNotSupported } return s.Internal.StorageAddLocal(p0, p1) } -func (s *CurioStub) StorageAddLocal(p0 context.Context, p1 string) error { +func (s *CurioStub) StorageAddLocal(p0 context.Context, p1 string) (error) { return ErrNotSupported } -func (s *CurioStruct) StorageDetachLocal(p0 context.Context, p1 string) error { +func (s *CurioStruct) StorageDetachLocal(p0 context.Context, p1 string) (error) { if s.Internal.StorageDetachLocal == nil { return ErrNotSupported } return s.Internal.StorageDetachLocal(p0, p1) } -func (s *CurioStub) StorageDetachLocal(p0 context.Context, p1 string) error { +func (s *CurioStub) StorageDetachLocal(p0 context.Context, p1 string) (error) { return ErrNotSupported } @@ -368,14 +469,14 @@ func (s *CurioStub) StorageInfo(p0 context.Context, p1 storiface.ID) (storiface. return *new(storiface.StorageInfo), ErrNotSupported } -func (s *CurioStruct) StorageInit(p0 context.Context, p1 string, p2 storiface.LocalStorageMeta) error { +func (s *CurioStruct) StorageInit(p0 context.Context, p1 string, p2 storiface.LocalStorageMeta) (error) { if s.Internal.StorageInit == nil { return ErrNotSupported } return s.Internal.StorageInit(p0, p1, p2) } -func (s *CurioStub) StorageInit(p0 context.Context, p1 string, p2 storiface.LocalStorageMeta) error { +func (s *CurioStub) StorageInit(p0 context.Context, p1 string, p2 storiface.LocalStorageMeta) (error) { return ErrNotSupported } @@ -401,14 +502,14 @@ func (s *CurioStub) StorageLocal(p0 context.Context) (map[storiface.ID]string, e return *new(map[storiface.ID]string), ErrNotSupported } -func (s *CurioStruct) StorageRedeclare(p0 context.Context, p1 *storiface.ID, p2 bool) error { +func (s *CurioStruct) StorageRedeclare(p0 context.Context, p1 *storiface.ID, p2 bool) (error) { if s.Internal.StorageRedeclare == nil { return ErrNotSupported } return s.Internal.StorageRedeclare(p0, p1, p2) } -func (s *CurioStub) StorageRedeclare(p0 context.Context, p1 *storiface.ID, p2 bool) error { +func (s *CurioStub) StorageRedeclare(p0 context.Context, p1 *storiface.ID, p2 bool) (error) { return ErrNotSupported } @@ -423,14 +524,14 @@ func (s *CurioStub) StorageStat(p0 context.Context, p1 storiface.ID) (fsutil.FsS return *new(fsutil.FsStat), ErrNotSupported } -func (s *CurioStruct) Uncordon(p0 context.Context) error { +func (s *CurioStruct) Uncordon(p0 context.Context) (error) { if s.Internal.Uncordon == nil { return ErrNotSupported } return s.Internal.Uncordon(p0) } -func (s *CurioStub) Uncordon(p0 context.Context) error { +func (s *CurioStub) Uncordon(p0 context.Context) (error) { return ErrNotSupported } @@ -445,6 +546,9 @@ func (s *CurioStub) Version(p0 context.Context) ([]int, error) { return *new([]int), ErrNotSupported } + + + func (s *CurioChainRPCStruct) AuthNew(p0 context.Context, p1 []auth.Permission) ([]byte, error) { if s.Internal.AuthNew == nil { return *new([]byte), ErrNotSupported @@ -544,14 +648,14 @@ func (s *CurioChainRPCStub) ChainNotify(p0 context.Context) (<-chan []*api.HeadC return nil, ErrNotSupported } -func (s *CurioChainRPCStruct) ChainPutObj(p0 context.Context, p1 blocks.Block) error { +func (s *CurioChainRPCStruct) ChainPutObj(p0 context.Context, p1 blocks.Block) (error) { if s.Internal.ChainPutObj == nil { return ErrNotSupported } return s.Internal.ChainPutObj(p0, p1) } -func (s *CurioChainRPCStub) ChainPutObj(p0 context.Context, p1 blocks.Block) error { +func (s *CurioChainRPCStub) ChainPutObj(p0 context.Context, p1 blocks.Block) (error) { return ErrNotSupported } @@ -698,14 +802,14 @@ func (s *CurioChainRPCStub) Session(p0 context.Context) (uuid.UUID, error) { return *new(uuid.UUID), ErrNotSupported } -func (s *CurioChainRPCStruct) Shutdown(p0 context.Context) error { +func (s *CurioChainRPCStruct) Shutdown(p0 context.Context) (error) { if s.Internal.Shutdown == nil { return ErrNotSupported } return s.Internal.Shutdown(p0) } -func (s *CurioChainRPCStub) Shutdown(p0 context.Context) error { +func (s *CurioChainRPCStub) Shutdown(p0 context.Context) (error) { return ErrNotSupported } @@ -1160,14 +1264,14 @@ func (s *CurioChainRPCStub) StateWaitMsg(p0 context.Context, p1 cid.Cid, p2 uint return nil, ErrNotSupported } -func (s *CurioChainRPCStruct) SyncSubmitBlock(p0 context.Context, p1 *types.BlockMsg) error { +func (s *CurioChainRPCStruct) SyncSubmitBlock(p0 context.Context, p1 *types.BlockMsg) (error) { if s.Internal.SyncSubmitBlock == nil { return ErrNotSupported } return s.Internal.SyncSubmitBlock(p0, p1) } -func (s *CurioChainRPCStub) SyncSubmitBlock(p0 context.Context, p1 *types.BlockMsg) error { +func (s *CurioChainRPCStub) SyncSubmitBlock(p0 context.Context, p1 *types.BlockMsg) (error) { return ErrNotSupported } @@ -1226,5 +1330,9 @@ func (s *CurioChainRPCStub) WalletSignMessage(p0 context.Context, p1 address.Add return nil, ErrNotSupported } + + var _ Curio = new(CurioStruct) var _ CurioChainRPC = new(CurioChainRPCStruct) + + diff --git a/cuhttp/server.go b/cuhttp/server.go index c315f6f75..ff61e724c 100644 --- a/cuhttp/server.go +++ b/cuhttp/server.go @@ -154,8 +154,8 @@ func StartHTTPServer(ctx context.Context, d *deps.Deps, sd *ServiceDeps) error { chiRouter.Use(secureHeaders(cfg.CSP)) chiRouter.Use(corsHeaders) - if cfg.EnableCORS { - chiRouter.Use(handlers.CORS(handlers.AllowedOrigins([]string{"https://" + cfg.DomainName}))) + if len(cfg.CORSOrigins) > 0 { + chiRouter.Use(handlers.CORS(handlers.AllowedOrigins(cfg.CORSOrigins))) } // Set up the compression middleware with custom compression levels diff --git a/deps/config/doc_gen.go b/deps/config/doc_gen.go index b1583813b..e89e1b0ce 100644 --- a/deps/config/doc_gen.go +++ b/deps/config/doc_gen.go @@ -902,10 +902,11 @@ Time duration string (e.g., "1h2m3s") in TOML format. (Default: "5m0s")`, Time duration string (e.g., "1h2m3s") in TOML format. (Default: "5m0s")`, }, { - Name: "EnableCORS", - Type: "bool", + Name: "CORSOrigins", + Type: "[]string", - Comment: `EnableCORS indicates whether Cross-Origin Resource Sharing (CORS) is enabled or not.`, + Comment: `CORSOrigins specifies the allowed origins for CORS requests. If empty, CORS is disabled. +If not empty, only the specified origins will be allowed for CORS requests.`, }, { Name: "CSP", diff --git a/deps/config/types.go b/deps/config/types.go index 89dfb9888..4b66ecf60 100644 --- a/deps/config/types.go +++ b/deps/config/types.go @@ -131,7 +131,7 @@ func DefaultCurioConfig() *CurioConfig { ReadTimeout: time.Second * 10, IdleTimeout: time.Hour, ReadHeaderTimeout: time.Second * 5, - EnableCORS: true, + CORSOrigins: []string{}, CSP: "inline", CompressionLevels: CompressionConfig{ GzipLevel: 6, @@ -862,8 +862,9 @@ type HTTPConfig struct { // Time duration string (e.g., "1h2m3s") in TOML format. (Default: "5m0s") ReadHeaderTimeout time.Duration - // EnableCORS indicates whether Cross-Origin Resource Sharing (CORS) is enabled or not. - EnableCORS bool + // CORSOrigins specifies the allowed origins for CORS requests. If empty, CORS is disabled. + // If not empty, only the specified origins will be allowed for CORS requests. + CORSOrigins []string // CSP sets the Content Security Policy for content served via the /piece/ retrieval endpoint. // Valid values: "off", "self", "inline" (Default: "inline") diff --git a/documentation/en/configuration/default-curio-configuration.md b/documentation/en/configuration/default-curio-configuration.md index e6235a4d1..62baf4321 100644 --- a/documentation/en/configuration/default-curio-configuration.md +++ b/documentation/en/configuration/default-curio-configuration.md @@ -558,10 +558,11 @@ description: The default curio configuration # type: time.Duration #ReadHeaderTimeout = "5s" - # EnableCORS indicates whether Cross-Origin Resource Sharing (CORS) is enabled or not. + # CORSOrigins specifies the allowed origins for CORS requests. If empty, CORS is disabled. + # If not empty, only the specified origins will be allowed for CORS requests. # - # type: bool - #EnableCORS = true + # type: []string + #CORSOrigins = [] # CSP sets the Content Security Policy for content served via the /piece/ retrieval endpoint. # Valid values: "off", "self", "inline" (Default: "inline") diff --git a/documentation/en/curio-market/curio-http-server.md b/documentation/en/curio-market/curio-http-server.md index da6f98905..59850726a 100644 --- a/documentation/en/curio-market/curio-http-server.md +++ b/documentation/en/curio-market/curio-http-server.md @@ -114,8 +114,8 @@ The Curio HTTP Server can be customized using the `HTTPConfig` structure, which Default: `2 minutes` — Prevents resources from being consumed by idle connections. If your application expects longer periods of inactivity, such as in long polling or WebSocket connections, this value should be adjusted accordingly. * **ReadHeaderTimeout**: The time allowed to read the request headers from the client.\ Default: `5 seconds` — Prevents slow clients from keeping connections open without sending complete headers. For standard web traffic, this value is sufficient, but it may need adjustment for certain client environments. -* **EnableCORS**: A boolean flag to enable or disable Cross-Origin Resource Sharing (CORS).\ - Default: `true` — This allows cross-origin requests, which is important for web applications that might make API calls from different domains. +* **CORSOrigins**: Specifies the allowed origins for CORS requests. If empty, CORS is disabled.\ + Default: `[]` (empty array) — This disables CORS by default for security. To enable CORS, specify the allowed origins (e.g., `["https://example.com", "https://app.example.com"]`). * **CompressionLevels**: Defines the compression levels for GZIP, Brotli, and Deflate, which are used to optimize the response size. The defaults balance performance and bandwidth savings: * **GzipLevel**: Default: `6` — A moderate compression level that balances speed and compression ratio, suitable for general-purpose use. * **BrotliLevel**: Default: `4` — A moderate Brotli compression level, which provides better compression than GZIP but is more CPU-intensive. This level is good for text-heavy responses like HTML or JSON. diff --git a/web/srv.go b/web/srv.go index 92d99ae48..df1fa21e4 100644 --- a/web/srv.go +++ b/web/srv.go @@ -17,6 +17,7 @@ import ( "strings" "time" + "github.com/gorilla/handlers" "github.com/gorilla/mux" "github.com/gorilla/websocket" logging "github.com/ipfs/go-log/v2" @@ -41,7 +42,11 @@ var webDev = os.Getenv("CURIO_WEB_DEV") == "1" func GetSrv(ctx context.Context, deps *deps.Deps, devMode bool) (*http.Server, error) { mx := mux.NewRouter() - mx.Use(corsMiddleware) + + // Add CORS middleware if origins are configured + if len(deps.Cfg.HTTP.CORSOrigins) > 0 { + mx.Use(handlers.CORS(handlers.AllowedOrigins(deps.Cfg.HTTP.CORSOrigins))) + } if !devMode { api.Routes(mx.PathPrefix("/api").Subrouter(), deps, webDev) @@ -278,19 +283,3 @@ func proxyCopy(dst, src *websocket.Conn, errc chan<- error, direction string) { } } } - -func corsMiddleware(next http.Handler) http.Handler { - return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - w.Header().Set("Access-Control-Allow-Origin", "*") - w.Header().Set("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS") - w.Header().Set("Access-Control-Allow-Headers", "Accept, Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization") - w.Header().Set("Access-Control-Allow-Credentials", "true") - - if r.Method == http.MethodOptions { - w.WriteHeader(http.StatusOK) - return - } - - next.ServeHTTP(w, r) - }) -} From 7f842b73971d39b729db386b7f6300657cc53bdf Mon Sep 17 00:00:00 2001 From: "Andrew Jackson (Ajax)" Date: Wed, 24 Sep 2025 17:06:12 -0500 Subject: [PATCH 02/11] doc --- deps/config/doc_gen.go | 2 +- documentation/en/configuration/default-curio-configuration.md | 2 +- documentation/en/curio-market/curio-http-server.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/deps/config/doc_gen.go b/deps/config/doc_gen.go index e89e1b0ce..d06d3b817 100644 --- a/deps/config/doc_gen.go +++ b/deps/config/doc_gen.go @@ -906,7 +906,7 @@ Time duration string (e.g., "1h2m3s") in TOML format. (Default: "5m0s")`, Type: "[]string", Comment: `CORSOrigins specifies the allowed origins for CORS requests. If empty, CORS is disabled. -If not empty, only the specified origins will be allowed for CORS requests.`, +If not empty, only the specified origins will be allowed for CORS requests This is `, }, { Name: "CSP", diff --git a/documentation/en/configuration/default-curio-configuration.md b/documentation/en/configuration/default-curio-configuration.md index 62baf4321..879191453 100644 --- a/documentation/en/configuration/default-curio-configuration.md +++ b/documentation/en/configuration/default-curio-configuration.md @@ -559,7 +559,7 @@ description: The default curio configuration #ReadHeaderTimeout = "5s" # CORSOrigins specifies the allowed origins for CORS requests. If empty, CORS is disabled. - # If not empty, only the specified origins will be allowed for CORS requests. + # If not empty, only the specified origins will be allowed for CORS requests. This is required for third-party UI servers. # # type: []string #CORSOrigins = [] diff --git a/documentation/en/curio-market/curio-http-server.md b/documentation/en/curio-market/curio-http-server.md index 59850726a..95a037160 100644 --- a/documentation/en/curio-market/curio-http-server.md +++ b/documentation/en/curio-market/curio-http-server.md @@ -115,7 +115,7 @@ The Curio HTTP Server can be customized using the `HTTPConfig` structure, which * **ReadHeaderTimeout**: The time allowed to read the request headers from the client.\ Default: `5 seconds` — Prevents slow clients from keeping connections open without sending complete headers. For standard web traffic, this value is sufficient, but it may need adjustment for certain client environments. * **CORSOrigins**: Specifies the allowed origins for CORS requests. If empty, CORS is disabled.\ - Default: `[]` (empty array) — This disables CORS by default for security. To enable CORS, specify the allowed origins (e.g., `["https://example.com", "https://app.example.com"]`). + Default: `[]` (empty array) — This disables CORS by default for security. To enable CORS, specify the allowed origins (e.g., `["https://example.com", "https://app.example.com"]`). This is required for third-party UI servers. * **CompressionLevels**: Defines the compression levels for GZIP, Brotli, and Deflate, which are used to optimize the response size. The defaults balance performance and bandwidth savings: * **GzipLevel**: Default: `6` — A moderate compression level that balances speed and compression ratio, suitable for general-purpose use. * **BrotliLevel**: Default: `4` — A moderate Brotli compression level, which provides better compression than GZIP but is more CPU-intensive. This level is good for text-heavy responses like HTML or JSON. From c89537629a817e015c98fe1398f1520e6a4e2d83 Mon Sep 17 00:00:00 2001 From: "Andrew Jackson (Ajax)" Date: Wed, 24 Sep 2025 19:35:39 -0500 Subject: [PATCH 03/11] make gen --- lib/paths/mocks/index.go | 7 ++----- lib/paths/mocks/pf.go | 6 ++---- lib/paths/mocks/store.go | 9 +++------ 3 files changed, 7 insertions(+), 15 deletions(-) diff --git a/lib/paths/mocks/index.go b/lib/paths/mocks/index.go index 082d22908..110b76818 100644 --- a/lib/paths/mocks/index.go +++ b/lib/paths/mocks/index.go @@ -8,14 +8,11 @@ import ( context "context" reflect "reflect" - gomock "github.com/golang/mock/gomock" - - abi "github.com/filecoin-project/go-state-types/abi" - paths "github.com/filecoin-project/curio/lib/paths" storiface "github.com/filecoin-project/curio/lib/storiface" - + abi "github.com/filecoin-project/go-state-types/abi" fsutil "github.com/filecoin-project/lotus/storage/sealer/fsutil" + gomock "github.com/golang/mock/gomock" ) // MockSectorIndex is a mock of SectorIndex interface. diff --git a/lib/paths/mocks/pf.go b/lib/paths/mocks/pf.go index 072e47b2e..ee181dcba 100644 --- a/lib/paths/mocks/pf.go +++ b/lib/paths/mocks/pf.go @@ -8,12 +8,10 @@ import ( io "io" reflect "reflect" - gomock "github.com/golang/mock/gomock" - - abi "github.com/filecoin-project/go-state-types/abi" - partialfile "github.com/filecoin-project/curio/lib/partialfile" storiface "github.com/filecoin-project/curio/lib/storiface" + abi "github.com/filecoin-project/go-state-types/abi" + gomock "github.com/golang/mock/gomock" ) // MockPartialFileHandler is a mock of PartialFileHandler interface. diff --git a/lib/paths/mocks/store.go b/lib/paths/mocks/store.go index e7c3c184c..816a392af 100644 --- a/lib/paths/mocks/store.go +++ b/lib/paths/mocks/store.go @@ -8,14 +8,11 @@ import ( context "context" reflect "reflect" - gomock "github.com/golang/mock/gomock" - cid "github.com/ipfs/go-cid" - - abi "github.com/filecoin-project/go-state-types/abi" - storiface "github.com/filecoin-project/curio/lib/storiface" - + abi "github.com/filecoin-project/go-state-types/abi" fsutil "github.com/filecoin-project/lotus/storage/sealer/fsutil" + gomock "github.com/golang/mock/gomock" + cid "github.com/ipfs/go-cid" ) // MockStore is a mock of Store interface. From 8bc528720752616da223e977b937be14774cd2e0 Mon Sep 17 00:00:00 2001 From: "Andrew Jackson (Ajax)" Date: Wed, 24 Sep 2025 23:48:59 -0500 Subject: [PATCH 04/11] formatted --- .github/workflows/ci.yml | 2 +- api/proxy_gen.go | 206 ++++++++++----------------------------- lib/paths/mocks/index.go | 7 +- lib/paths/mocks/pf.go | 6 +- lib/paths/mocks/store.go | 9 +- 5 files changed, 65 insertions(+), 165 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8c3c95c25..89dc8c797 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -203,7 +203,7 @@ jobs: id: start-yugabyte run: | # Start YugabyteDB container with dynamic port mapping for PostgreSQL and YCQL - docker run --rm --name ${{ env.CONTAINER_NAME }} -d yugabytedb/yugabyte:2024.1.2.0-b77 bin/yugabyted start --daemon=false + docker run --rm --name ${{ env.CONTAINER_NAME }} -d yugabytedb/yugabyte:latest bin/yugabyted start --daemon=false - name: Wait for YugabyteDB to start run: | diff --git a/api/proxy_gen.go b/api/proxy_gen.go index 7737717e1..114481675 100644 --- a/api/proxy_gen.go +++ b/api/proxy_gen.go @@ -4,8 +4,16 @@ package api import ( "context" - ltypes "github.com/filecoin-project/curio/api/types" - "github.com/filecoin-project/curio/lib/storiface" + "net/http" + "net/url" + "reflect" + + "github.com/google/uuid" + blocks "github.com/ipfs/go-block-format" + "github.com/ipfs/go-cid" + "github.com/multiformats/go-multihash" + "golang.org/x/xerrors" + "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-bitfield" "github.com/filecoin-project/go-jsonrpc/auth" @@ -15,328 +23,219 @@ import ( "github.com/filecoin-project/go-state-types/crypto" "github.com/filecoin-project/go-state-types/dline" "github.com/filecoin-project/go-state-types/network" + + ltypes "github.com/filecoin-project/curio/api/types" + "github.com/filecoin-project/curio/lib/storiface" + "github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/chain/actors/builtin/miner" "github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/node/modules/dtypes" lpiece "github.com/filecoin-project/lotus/storage/pipeline/piece" "github.com/filecoin-project/lotus/storage/sealer/fsutil" - "github.com/google/uuid" - blocks "github.com/ipfs/go-block-format" - "github.com/ipfs/go-cid" - "github.com/multiformats/go-multihash" - "net/http" - "net/url" - "reflect" - - "golang.org/x/xerrors" ) - var _ = reflect.TypeOf([]byte(nil)) var ErrNotSupported = xerrors.New("method not supported") - type CurioStruct struct { - Internal CurioMethods } type CurioMethods struct { - AllocatePieceToSector func(p0 context.Context, p1 address.Address, p2 lpiece.PieceDealInfo, p3 int64, p4 url.URL, p5 http.Header) (api.SectorOffset, error) `perm:"write"` - - Cordon func(p0 context.Context) (error) `perm:"admin"` - + Cordon func(p0 context.Context) error `perm:"admin"` IndexSamples func(p0 context.Context, p1 cid.Cid) ([]multihash.Multihash, error) `perm:"admin"` - Info func(p0 context.Context) (*ltypes.NodeInfo, error) `perm:"read"` - LogList func(p0 context.Context) ([]string, error) `perm:"read"` + LogSetLevel func(p0 context.Context, p1 string, p2 string) error `perm:"admin"` - LogSetLevel func(p0 context.Context, p1 string, p2 string) (error) `perm:"admin"` - - - Shutdown func(p0 context.Context) (error) `perm:"admin"` + Shutdown func(p0 context.Context) error `perm:"admin"` + StorageAddLocal func(p0 context.Context, p1 string) error `perm:"admin"` - StorageAddLocal func(p0 context.Context, p1 string) (error) `perm:"admin"` - - - StorageDetachLocal func(p0 context.Context, p1 string) (error) `perm:"admin"` - + StorageDetachLocal func(p0 context.Context, p1 string) error `perm:"admin"` StorageFindSector func(p0 context.Context, p1 abi.SectorID, p2 storiface.SectorFileType, p3 abi.SectorSize, p4 bool) ([]storiface.SectorStorageInfo, error) `perm:"admin"` - StorageGenerateVanillaProof func(p0 context.Context, p1 address.Address, p2 abi.SectorNumber) ([]byte, error) `perm:"admin"` - StorageInfo func(p0 context.Context, p1 storiface.ID) (storiface.StorageInfo, error) `perm:"admin"` - - StorageInit func(p0 context.Context, p1 string, p2 storiface.LocalStorageMeta) (error) `perm:"admin"` - + StorageInit func(p0 context.Context, p1 string, p2 storiface.LocalStorageMeta) error `perm:"admin"` StorageList func(p0 context.Context) (map[storiface.ID][]storiface.Decl, error) `perm:"admin"` - StorageLocal func(p0 context.Context) (map[storiface.ID]string, error) `perm:"admin"` - - StorageRedeclare func(p0 context.Context, p1 *storiface.ID, p2 bool) (error) `perm:"admin"` - + StorageRedeclare func(p0 context.Context, p1 *storiface.ID, p2 bool) error `perm:"admin"` StorageStat func(p0 context.Context, p1 storiface.ID) (fsutil.FsStat, error) `perm:"admin"` - - Uncordon func(p0 context.Context) (error) `perm:"admin"` - + Uncordon func(p0 context.Context) error `perm:"admin"` Version func(p0 context.Context) ([]int, error) `perm:"admin"` - - - } +} type CurioStub struct { - } type CurioChainRPCStruct struct { - Internal CurioChainRPCMethods } type CurioChainRPCMethods struct { - AuthNew func(p0 context.Context, p1 []auth.Permission) ([]byte, error) `perm:"admin"` - AuthVerify func(p0 context.Context, p1 string) ([]auth.Permission, error) `perm:"read"` - ChainGetMessage func(p0 context.Context, p1 cid.Cid) (*types.Message, error) `` - ChainGetTipSet func(p0 context.Context, p1 types.TipSetKey) (*types.TipSet, error) `` - ChainGetTipSetAfterHeight func(p0 context.Context, p1 abi.ChainEpoch, p2 types.TipSetKey) (*types.TipSet, error) `` - ChainGetTipSetByHeight func(p0 context.Context, p1 abi.ChainEpoch, p2 types.TipSetKey) (*types.TipSet, error) `` - ChainHasObj func(p0 context.Context, p1 cid.Cid) (bool, error) `` - ChainHead func(p0 context.Context) (*types.TipSet, error) `` - ChainNotify func(p0 context.Context) (<-chan []*api.HeadChange, error) `` - - ChainPutObj func(p0 context.Context, p1 blocks.Block) (error) `` - + ChainPutObj func(p0 context.Context, p1 blocks.Block) error `` ChainReadObj func(p0 context.Context, p1 cid.Cid) ([]byte, error) `` - ChainTipSetWeight func(p0 context.Context, p1 types.TipSetKey) (types.BigInt, error) `` - GasEstimateFeeCap func(p0 context.Context, p1 *types.Message, p2 int64, p3 types.TipSetKey) (types.BigInt, error) `` - GasEstimateGasPremium func(p0 context.Context, p1 uint64, p2 address.Address, p3 int64, p4 types.TipSetKey) (types.BigInt, error) `` - GasEstimateMessageGas func(p0 context.Context, p1 *types.Message, p2 *api.MessageSendSpec, p3 types.TipSetKey) (*types.Message, error) `` - MarketAddBalance func(p0 context.Context, p1 address.Address, p2 address.Address, p3 types.BigInt) (cid.Cid, error) `` - MinerCreateBlock func(p0 context.Context, p1 *api.BlockTemplate) (*types.BlockMsg, error) `` - MinerGetBaseInfo func(p0 context.Context, p1 address.Address, p2 abi.ChainEpoch, p3 types.TipSetKey) (*api.MiningBaseInfo, error) `` - MpoolGetNonce func(p0 context.Context, p1 address.Address) (uint64, error) `` - MpoolPush func(p0 context.Context, p1 *types.SignedMessage) (cid.Cid, error) `` - MpoolPushMessage func(p0 context.Context, p1 *types.Message, p2 *api.MessageSendSpec) (*types.SignedMessage, error) `` - MpoolSelect func(p0 context.Context, p1 types.TipSetKey, p2 float64) ([]*types.SignedMessage, error) `` - Session func(p0 context.Context) (uuid.UUID, error) `perm:"read"` - - Shutdown func(p0 context.Context) (error) `perm:"admin"` - + Shutdown func(p0 context.Context) error `perm:"admin"` StateAccountKey func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (address.Address, error) `` - StateCall func(p0 context.Context, p1 *types.Message, p2 types.TipSetKey) (*api.InvocResult, error) `` - StateCirculatingSupply func(p0 context.Context, p1 types.TipSetKey) (big.Int, error) `` - StateDealProviderCollateralBounds func(p0 context.Context, p1 abi.PaddedPieceSize, p2 bool, p3 types.TipSetKey) (api.DealCollateralBounds, error) `` - StateGetActor func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (*types.Actor, error) `` - StateGetAllocation func(p0 context.Context, p1 address.Address, p2 verifregtypes.AllocationId, p3 types.TipSetKey) (*verifregtypes.Allocation, error) `` - StateGetAllocationForPendingDeal func(p0 context.Context, p1 abi.DealID, p2 types.TipSetKey) (*verifregtypes.Allocation, error) `` - StateGetAllocationIdForPendingDeal func(p0 context.Context, p1 abi.DealID, p2 types.TipSetKey) (verifregtypes.AllocationId, error) `` - StateGetBeaconEntry func(p0 context.Context, p1 abi.ChainEpoch) (*types.BeaconEntry, error) `` - StateGetRandomnessFromBeacon func(p0 context.Context, p1 crypto.DomainSeparationTag, p2 abi.ChainEpoch, p3 []byte, p4 types.TipSetKey) (abi.Randomness, error) `` - StateGetRandomnessFromTickets func(p0 context.Context, p1 crypto.DomainSeparationTag, p2 abi.ChainEpoch, p3 []byte, p4 types.TipSetKey) (abi.Randomness, error) `` - StateListMessages func(p0 context.Context, p1 *api.MessageMatch, p2 types.TipSetKey, p3 abi.ChainEpoch) ([]cid.Cid, error) `` - StateListMiners func(p0 context.Context, p1 types.TipSetKey) ([]address.Address, error) `` - StateLookupID func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (address.Address, error) `` - StateMarketBalance func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (api.MarketBalance, error) `` - StateMarketStorageDeal func(p0 context.Context, p1 abi.DealID, p2 types.TipSetKey) (*api.MarketDeal, error) `` - StateMinerActiveSectors func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) ([]*miner.SectorOnChainInfo, error) `` - StateMinerAllocated func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (*bitfield.BitField, error) `` - StateMinerAvailableBalance func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (types.BigInt, error) `perm:"read"` - StateMinerCreationDeposit func(p0 context.Context, p1 types.TipSetKey) (types.BigInt, error) `` - StateMinerDeadlines func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) ([]api.Deadline, error) `perm:"read"` - StateMinerFaults func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (bitfield.BitField, error) `` - StateMinerInfo func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (api.MinerInfo, error) `` - StateMinerInitialPledgeForSector func(p0 context.Context, p1 abi.ChainEpoch, p2 abi.SectorSize, p3 uint64, p4 types.TipSetKey) (types.BigInt, error) `` - StateMinerPartitions func(p0 context.Context, p1 address.Address, p2 uint64, p3 types.TipSetKey) ([]api.Partition, error) `` - StateMinerPower func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (*api.MinerPower, error) `perm:"read"` - StateMinerPreCommitDepositForPower func(p0 context.Context, p1 address.Address, p2 miner.SectorPreCommitInfo, p3 types.TipSetKey) (big.Int, error) `` - StateMinerProvingDeadline func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (*dline.Info, error) `` - StateMinerRecoveries func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (bitfield.BitField, error) `` - StateMinerSectorCount func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (api.MinerSectors, error) `` - StateMinerSectors func(p0 context.Context, p1 address.Address, p2 *bitfield.BitField, p3 types.TipSetKey) ([]*miner.SectorOnChainInfo, error) `` - StateNetworkName func(p0 context.Context) (dtypes.NetworkName, error) `` - StateNetworkVersion func(p0 context.Context, p1 types.TipSetKey) (network.Version, error) `` - StateReadState func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (*api.ActorState, error) `` - StateSearchMsg func(p0 context.Context, p1 types.TipSetKey, p2 cid.Cid, p3 abi.ChainEpoch, p4 bool) (*api.MsgLookup, error) `` - StateSectorGetInfo func(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (*miner.SectorOnChainInfo, error) `` - StateSectorPartition func(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (*miner.SectorLocation, error) `` - StateSectorPreCommitInfo func(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (*miner.SectorPreCommitOnChainInfo, error) `` - StateVMCirculatingSupplyInternal func(p0 context.Context, p1 types.TipSetKey) (api.CirculatingSupply, error) `` - StateVerifiedClientStatus func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (*abi.StoragePower, error) `` - StateWaitMsg func(p0 context.Context, p1 cid.Cid, p2 uint64, p3 abi.ChainEpoch, p4 bool) (*api.MsgLookup, error) `perm:"read"` - - SyncSubmitBlock func(p0 context.Context, p1 *types.BlockMsg) (error) `` - + SyncSubmitBlock func(p0 context.Context, p1 *types.BlockMsg) error `` Version func(p0 context.Context) (api.APIVersion, error) `perm:"read"` - WalletBalance func(p0 context.Context, p1 address.Address) (big.Int, error) `` - WalletHas func(p0 context.Context, p1 address.Address) (bool, error) `` - WalletSign func(p0 context.Context, p1 address.Address, p2 []byte) (*crypto.Signature, error) `` - WalletSignMessage func(p0 context.Context, p1 address.Address, p2 *types.Message) (*types.SignedMessage, error) `` - - - } +} type CurioChainRPCStub struct { - } - - - - func (s *CurioStruct) AllocatePieceToSector(p0 context.Context, p1 address.Address, p2 lpiece.PieceDealInfo, p3 int64, p4 url.URL, p5 http.Header) (api.SectorOffset, error) { if s.Internal.AllocatePieceToSector == nil { return *new(api.SectorOffset), ErrNotSupported @@ -348,14 +247,14 @@ func (s *CurioStub) AllocatePieceToSector(p0 context.Context, p1 address.Address return *new(api.SectorOffset), ErrNotSupported } -func (s *CurioStruct) Cordon(p0 context.Context) (error) { +func (s *CurioStruct) Cordon(p0 context.Context) error { if s.Internal.Cordon == nil { return ErrNotSupported } return s.Internal.Cordon(p0) } -func (s *CurioStub) Cordon(p0 context.Context) (error) { +func (s *CurioStub) Cordon(p0 context.Context) error { return ErrNotSupported } @@ -392,47 +291,47 @@ func (s *CurioStub) LogList(p0 context.Context) ([]string, error) { return *new([]string), ErrNotSupported } -func (s *CurioStruct) LogSetLevel(p0 context.Context, p1 string, p2 string) (error) { +func (s *CurioStruct) LogSetLevel(p0 context.Context, p1 string, p2 string) error { if s.Internal.LogSetLevel == nil { return ErrNotSupported } return s.Internal.LogSetLevel(p0, p1, p2) } -func (s *CurioStub) LogSetLevel(p0 context.Context, p1 string, p2 string) (error) { +func (s *CurioStub) LogSetLevel(p0 context.Context, p1 string, p2 string) error { return ErrNotSupported } -func (s *CurioStruct) Shutdown(p0 context.Context) (error) { +func (s *CurioStruct) Shutdown(p0 context.Context) error { if s.Internal.Shutdown == nil { return ErrNotSupported } return s.Internal.Shutdown(p0) } -func (s *CurioStub) Shutdown(p0 context.Context) (error) { +func (s *CurioStub) Shutdown(p0 context.Context) error { return ErrNotSupported } -func (s *CurioStruct) StorageAddLocal(p0 context.Context, p1 string) (error) { +func (s *CurioStruct) StorageAddLocal(p0 context.Context, p1 string) error { if s.Internal.StorageAddLocal == nil { return ErrNotSupported } return s.Internal.StorageAddLocal(p0, p1) } -func (s *CurioStub) StorageAddLocal(p0 context.Context, p1 string) (error) { +func (s *CurioStub) StorageAddLocal(p0 context.Context, p1 string) error { return ErrNotSupported } -func (s *CurioStruct) StorageDetachLocal(p0 context.Context, p1 string) (error) { +func (s *CurioStruct) StorageDetachLocal(p0 context.Context, p1 string) error { if s.Internal.StorageDetachLocal == nil { return ErrNotSupported } return s.Internal.StorageDetachLocal(p0, p1) } -func (s *CurioStub) StorageDetachLocal(p0 context.Context, p1 string) (error) { +func (s *CurioStub) StorageDetachLocal(p0 context.Context, p1 string) error { return ErrNotSupported } @@ -469,14 +368,14 @@ func (s *CurioStub) StorageInfo(p0 context.Context, p1 storiface.ID) (storiface. return *new(storiface.StorageInfo), ErrNotSupported } -func (s *CurioStruct) StorageInit(p0 context.Context, p1 string, p2 storiface.LocalStorageMeta) (error) { +func (s *CurioStruct) StorageInit(p0 context.Context, p1 string, p2 storiface.LocalStorageMeta) error { if s.Internal.StorageInit == nil { return ErrNotSupported } return s.Internal.StorageInit(p0, p1, p2) } -func (s *CurioStub) StorageInit(p0 context.Context, p1 string, p2 storiface.LocalStorageMeta) (error) { +func (s *CurioStub) StorageInit(p0 context.Context, p1 string, p2 storiface.LocalStorageMeta) error { return ErrNotSupported } @@ -502,14 +401,14 @@ func (s *CurioStub) StorageLocal(p0 context.Context) (map[storiface.ID]string, e return *new(map[storiface.ID]string), ErrNotSupported } -func (s *CurioStruct) StorageRedeclare(p0 context.Context, p1 *storiface.ID, p2 bool) (error) { +func (s *CurioStruct) StorageRedeclare(p0 context.Context, p1 *storiface.ID, p2 bool) error { if s.Internal.StorageRedeclare == nil { return ErrNotSupported } return s.Internal.StorageRedeclare(p0, p1, p2) } -func (s *CurioStub) StorageRedeclare(p0 context.Context, p1 *storiface.ID, p2 bool) (error) { +func (s *CurioStub) StorageRedeclare(p0 context.Context, p1 *storiface.ID, p2 bool) error { return ErrNotSupported } @@ -524,14 +423,14 @@ func (s *CurioStub) StorageStat(p0 context.Context, p1 storiface.ID) (fsutil.FsS return *new(fsutil.FsStat), ErrNotSupported } -func (s *CurioStruct) Uncordon(p0 context.Context) (error) { +func (s *CurioStruct) Uncordon(p0 context.Context) error { if s.Internal.Uncordon == nil { return ErrNotSupported } return s.Internal.Uncordon(p0) } -func (s *CurioStub) Uncordon(p0 context.Context) (error) { +func (s *CurioStub) Uncordon(p0 context.Context) error { return ErrNotSupported } @@ -546,9 +445,6 @@ func (s *CurioStub) Version(p0 context.Context) ([]int, error) { return *new([]int), ErrNotSupported } - - - func (s *CurioChainRPCStruct) AuthNew(p0 context.Context, p1 []auth.Permission) ([]byte, error) { if s.Internal.AuthNew == nil { return *new([]byte), ErrNotSupported @@ -648,14 +544,14 @@ func (s *CurioChainRPCStub) ChainNotify(p0 context.Context) (<-chan []*api.HeadC return nil, ErrNotSupported } -func (s *CurioChainRPCStruct) ChainPutObj(p0 context.Context, p1 blocks.Block) (error) { +func (s *CurioChainRPCStruct) ChainPutObj(p0 context.Context, p1 blocks.Block) error { if s.Internal.ChainPutObj == nil { return ErrNotSupported } return s.Internal.ChainPutObj(p0, p1) } -func (s *CurioChainRPCStub) ChainPutObj(p0 context.Context, p1 blocks.Block) (error) { +func (s *CurioChainRPCStub) ChainPutObj(p0 context.Context, p1 blocks.Block) error { return ErrNotSupported } @@ -802,14 +698,14 @@ func (s *CurioChainRPCStub) Session(p0 context.Context) (uuid.UUID, error) { return *new(uuid.UUID), ErrNotSupported } -func (s *CurioChainRPCStruct) Shutdown(p0 context.Context) (error) { +func (s *CurioChainRPCStruct) Shutdown(p0 context.Context) error { if s.Internal.Shutdown == nil { return ErrNotSupported } return s.Internal.Shutdown(p0) } -func (s *CurioChainRPCStub) Shutdown(p0 context.Context) (error) { +func (s *CurioChainRPCStub) Shutdown(p0 context.Context) error { return ErrNotSupported } @@ -1264,14 +1160,14 @@ func (s *CurioChainRPCStub) StateWaitMsg(p0 context.Context, p1 cid.Cid, p2 uint return nil, ErrNotSupported } -func (s *CurioChainRPCStruct) SyncSubmitBlock(p0 context.Context, p1 *types.BlockMsg) (error) { +func (s *CurioChainRPCStruct) SyncSubmitBlock(p0 context.Context, p1 *types.BlockMsg) error { if s.Internal.SyncSubmitBlock == nil { return ErrNotSupported } return s.Internal.SyncSubmitBlock(p0, p1) } -func (s *CurioChainRPCStub) SyncSubmitBlock(p0 context.Context, p1 *types.BlockMsg) (error) { +func (s *CurioChainRPCStub) SyncSubmitBlock(p0 context.Context, p1 *types.BlockMsg) error { return ErrNotSupported } @@ -1330,9 +1226,5 @@ func (s *CurioChainRPCStub) WalletSignMessage(p0 context.Context, p1 address.Add return nil, ErrNotSupported } - - var _ Curio = new(CurioStruct) var _ CurioChainRPC = new(CurioChainRPCStruct) - - diff --git a/lib/paths/mocks/index.go b/lib/paths/mocks/index.go index 110b76818..082d22908 100644 --- a/lib/paths/mocks/index.go +++ b/lib/paths/mocks/index.go @@ -8,11 +8,14 @@ import ( context "context" reflect "reflect" + gomock "github.com/golang/mock/gomock" + + abi "github.com/filecoin-project/go-state-types/abi" + paths "github.com/filecoin-project/curio/lib/paths" storiface "github.com/filecoin-project/curio/lib/storiface" - abi "github.com/filecoin-project/go-state-types/abi" + fsutil "github.com/filecoin-project/lotus/storage/sealer/fsutil" - gomock "github.com/golang/mock/gomock" ) // MockSectorIndex is a mock of SectorIndex interface. diff --git a/lib/paths/mocks/pf.go b/lib/paths/mocks/pf.go index ee181dcba..072e47b2e 100644 --- a/lib/paths/mocks/pf.go +++ b/lib/paths/mocks/pf.go @@ -8,10 +8,12 @@ import ( io "io" reflect "reflect" + gomock "github.com/golang/mock/gomock" + + abi "github.com/filecoin-project/go-state-types/abi" + partialfile "github.com/filecoin-project/curio/lib/partialfile" storiface "github.com/filecoin-project/curio/lib/storiface" - abi "github.com/filecoin-project/go-state-types/abi" - gomock "github.com/golang/mock/gomock" ) // MockPartialFileHandler is a mock of PartialFileHandler interface. diff --git a/lib/paths/mocks/store.go b/lib/paths/mocks/store.go index 816a392af..e7c3c184c 100644 --- a/lib/paths/mocks/store.go +++ b/lib/paths/mocks/store.go @@ -8,11 +8,14 @@ import ( context "context" reflect "reflect" - storiface "github.com/filecoin-project/curio/lib/storiface" - abi "github.com/filecoin-project/go-state-types/abi" - fsutil "github.com/filecoin-project/lotus/storage/sealer/fsutil" gomock "github.com/golang/mock/gomock" cid "github.com/ipfs/go-cid" + + abi "github.com/filecoin-project/go-state-types/abi" + + storiface "github.com/filecoin-project/curio/lib/storiface" + + fsutil "github.com/filecoin-project/lotus/storage/sealer/fsutil" ) // MockStore is a mock of Store interface. From 417ad3b7abeda8605c5a1bced3f5b42ce0927f1c Mon Sep 17 00:00:00 2001 From: "Andrew Jackson (Ajax)" Date: Wed, 24 Sep 2025 23:54:10 -0500 Subject: [PATCH 05/11] undo yb change --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 89dc8c797..8c3c95c25 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -203,7 +203,7 @@ jobs: id: start-yugabyte run: | # Start YugabyteDB container with dynamic port mapping for PostgreSQL and YCQL - docker run --rm --name ${{ env.CONTAINER_NAME }} -d yugabytedb/yugabyte:latest bin/yugabyted start --daemon=false + docker run --rm --name ${{ env.CONTAINER_NAME }} -d yugabytedb/yugabyte:2024.1.2.0-b77 bin/yugabyted start --daemon=false - name: Wait for YugabyteDB to start run: | From b5d8b573aec5dcb1f5c13afb0c9812c7633f5ffc Mon Sep 17 00:00:00 2001 From: "Andrew Jackson (Ajax)" Date: Thu, 25 Sep 2025 11:14:41 -0500 Subject: [PATCH 06/11] gen --- api/proxy_gen.go | 206 +++++++++++++++++++++++++++++---------- deps/config/doc_gen.go | 3 +- deps/config/types.go | 1 + lib/paths/mocks/index.go | 7 +- lib/paths/mocks/pf.go | 6 +- lib/paths/mocks/store.go | 9 +- 6 files changed, 167 insertions(+), 65 deletions(-) diff --git a/api/proxy_gen.go b/api/proxy_gen.go index 114481675..7737717e1 100644 --- a/api/proxy_gen.go +++ b/api/proxy_gen.go @@ -4,16 +4,8 @@ package api import ( "context" - "net/http" - "net/url" - "reflect" - - "github.com/google/uuid" - blocks "github.com/ipfs/go-block-format" - "github.com/ipfs/go-cid" - "github.com/multiformats/go-multihash" - "golang.org/x/xerrors" - + ltypes "github.com/filecoin-project/curio/api/types" + "github.com/filecoin-project/curio/lib/storiface" "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-bitfield" "github.com/filecoin-project/go-jsonrpc/auth" @@ -23,219 +15,328 @@ import ( "github.com/filecoin-project/go-state-types/crypto" "github.com/filecoin-project/go-state-types/dline" "github.com/filecoin-project/go-state-types/network" - - ltypes "github.com/filecoin-project/curio/api/types" - "github.com/filecoin-project/curio/lib/storiface" - "github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/chain/actors/builtin/miner" "github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/node/modules/dtypes" lpiece "github.com/filecoin-project/lotus/storage/pipeline/piece" "github.com/filecoin-project/lotus/storage/sealer/fsutil" + "github.com/google/uuid" + blocks "github.com/ipfs/go-block-format" + "github.com/ipfs/go-cid" + "github.com/multiformats/go-multihash" + "net/http" + "net/url" + "reflect" + + "golang.org/x/xerrors" ) + var _ = reflect.TypeOf([]byte(nil)) var ErrNotSupported = xerrors.New("method not supported") + type CurioStruct struct { + Internal CurioMethods } type CurioMethods struct { + AllocatePieceToSector func(p0 context.Context, p1 address.Address, p2 lpiece.PieceDealInfo, p3 int64, p4 url.URL, p5 http.Header) (api.SectorOffset, error) `perm:"write"` - Cordon func(p0 context.Context) error `perm:"admin"` + + Cordon func(p0 context.Context) (error) `perm:"admin"` + IndexSamples func(p0 context.Context, p1 cid.Cid) ([]multihash.Multihash, error) `perm:"admin"` + Info func(p0 context.Context) (*ltypes.NodeInfo, error) `perm:"read"` + LogList func(p0 context.Context) ([]string, error) `perm:"read"` - LogSetLevel func(p0 context.Context, p1 string, p2 string) error `perm:"admin"` - Shutdown func(p0 context.Context) error `perm:"admin"` + LogSetLevel func(p0 context.Context, p1 string, p2 string) (error) `perm:"admin"` + + + Shutdown func(p0 context.Context) (error) `perm:"admin"` - StorageAddLocal func(p0 context.Context, p1 string) error `perm:"admin"` - StorageDetachLocal func(p0 context.Context, p1 string) error `perm:"admin"` + StorageAddLocal func(p0 context.Context, p1 string) (error) `perm:"admin"` + + + StorageDetachLocal func(p0 context.Context, p1 string) (error) `perm:"admin"` + StorageFindSector func(p0 context.Context, p1 abi.SectorID, p2 storiface.SectorFileType, p3 abi.SectorSize, p4 bool) ([]storiface.SectorStorageInfo, error) `perm:"admin"` + StorageGenerateVanillaProof func(p0 context.Context, p1 address.Address, p2 abi.SectorNumber) ([]byte, error) `perm:"admin"` + StorageInfo func(p0 context.Context, p1 storiface.ID) (storiface.StorageInfo, error) `perm:"admin"` - StorageInit func(p0 context.Context, p1 string, p2 storiface.LocalStorageMeta) error `perm:"admin"` + + StorageInit func(p0 context.Context, p1 string, p2 storiface.LocalStorageMeta) (error) `perm:"admin"` + StorageList func(p0 context.Context) (map[storiface.ID][]storiface.Decl, error) `perm:"admin"` + StorageLocal func(p0 context.Context) (map[storiface.ID]string, error) `perm:"admin"` - StorageRedeclare func(p0 context.Context, p1 *storiface.ID, p2 bool) error `perm:"admin"` + + StorageRedeclare func(p0 context.Context, p1 *storiface.ID, p2 bool) (error) `perm:"admin"` + StorageStat func(p0 context.Context, p1 storiface.ID) (fsutil.FsStat, error) `perm:"admin"` - Uncordon func(p0 context.Context) error `perm:"admin"` + + Uncordon func(p0 context.Context) (error) `perm:"admin"` + Version func(p0 context.Context) ([]int, error) `perm:"admin"` -} + + + } type CurioStub struct { + } type CurioChainRPCStruct struct { + Internal CurioChainRPCMethods } type CurioChainRPCMethods struct { + AuthNew func(p0 context.Context, p1 []auth.Permission) ([]byte, error) `perm:"admin"` + AuthVerify func(p0 context.Context, p1 string) ([]auth.Permission, error) `perm:"read"` + ChainGetMessage func(p0 context.Context, p1 cid.Cid) (*types.Message, error) `` + ChainGetTipSet func(p0 context.Context, p1 types.TipSetKey) (*types.TipSet, error) `` + ChainGetTipSetAfterHeight func(p0 context.Context, p1 abi.ChainEpoch, p2 types.TipSetKey) (*types.TipSet, error) `` + ChainGetTipSetByHeight func(p0 context.Context, p1 abi.ChainEpoch, p2 types.TipSetKey) (*types.TipSet, error) `` + ChainHasObj func(p0 context.Context, p1 cid.Cid) (bool, error) `` + ChainHead func(p0 context.Context) (*types.TipSet, error) `` + ChainNotify func(p0 context.Context) (<-chan []*api.HeadChange, error) `` - ChainPutObj func(p0 context.Context, p1 blocks.Block) error `` + + ChainPutObj func(p0 context.Context, p1 blocks.Block) (error) `` + ChainReadObj func(p0 context.Context, p1 cid.Cid) ([]byte, error) `` + ChainTipSetWeight func(p0 context.Context, p1 types.TipSetKey) (types.BigInt, error) `` + GasEstimateFeeCap func(p0 context.Context, p1 *types.Message, p2 int64, p3 types.TipSetKey) (types.BigInt, error) `` + GasEstimateGasPremium func(p0 context.Context, p1 uint64, p2 address.Address, p3 int64, p4 types.TipSetKey) (types.BigInt, error) `` + GasEstimateMessageGas func(p0 context.Context, p1 *types.Message, p2 *api.MessageSendSpec, p3 types.TipSetKey) (*types.Message, error) `` + MarketAddBalance func(p0 context.Context, p1 address.Address, p2 address.Address, p3 types.BigInt) (cid.Cid, error) `` + MinerCreateBlock func(p0 context.Context, p1 *api.BlockTemplate) (*types.BlockMsg, error) `` + MinerGetBaseInfo func(p0 context.Context, p1 address.Address, p2 abi.ChainEpoch, p3 types.TipSetKey) (*api.MiningBaseInfo, error) `` + MpoolGetNonce func(p0 context.Context, p1 address.Address) (uint64, error) `` + MpoolPush func(p0 context.Context, p1 *types.SignedMessage) (cid.Cid, error) `` + MpoolPushMessage func(p0 context.Context, p1 *types.Message, p2 *api.MessageSendSpec) (*types.SignedMessage, error) `` + MpoolSelect func(p0 context.Context, p1 types.TipSetKey, p2 float64) ([]*types.SignedMessage, error) `` + Session func(p0 context.Context) (uuid.UUID, error) `perm:"read"` - Shutdown func(p0 context.Context) error `perm:"admin"` + + Shutdown func(p0 context.Context) (error) `perm:"admin"` + StateAccountKey func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (address.Address, error) `` + StateCall func(p0 context.Context, p1 *types.Message, p2 types.TipSetKey) (*api.InvocResult, error) `` + StateCirculatingSupply func(p0 context.Context, p1 types.TipSetKey) (big.Int, error) `` + StateDealProviderCollateralBounds func(p0 context.Context, p1 abi.PaddedPieceSize, p2 bool, p3 types.TipSetKey) (api.DealCollateralBounds, error) `` + StateGetActor func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (*types.Actor, error) `` + StateGetAllocation func(p0 context.Context, p1 address.Address, p2 verifregtypes.AllocationId, p3 types.TipSetKey) (*verifregtypes.Allocation, error) `` + StateGetAllocationForPendingDeal func(p0 context.Context, p1 abi.DealID, p2 types.TipSetKey) (*verifregtypes.Allocation, error) `` + StateGetAllocationIdForPendingDeal func(p0 context.Context, p1 abi.DealID, p2 types.TipSetKey) (verifregtypes.AllocationId, error) `` + StateGetBeaconEntry func(p0 context.Context, p1 abi.ChainEpoch) (*types.BeaconEntry, error) `` + StateGetRandomnessFromBeacon func(p0 context.Context, p1 crypto.DomainSeparationTag, p2 abi.ChainEpoch, p3 []byte, p4 types.TipSetKey) (abi.Randomness, error) `` + StateGetRandomnessFromTickets func(p0 context.Context, p1 crypto.DomainSeparationTag, p2 abi.ChainEpoch, p3 []byte, p4 types.TipSetKey) (abi.Randomness, error) `` + StateListMessages func(p0 context.Context, p1 *api.MessageMatch, p2 types.TipSetKey, p3 abi.ChainEpoch) ([]cid.Cid, error) `` + StateListMiners func(p0 context.Context, p1 types.TipSetKey) ([]address.Address, error) `` + StateLookupID func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (address.Address, error) `` + StateMarketBalance func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (api.MarketBalance, error) `` + StateMarketStorageDeal func(p0 context.Context, p1 abi.DealID, p2 types.TipSetKey) (*api.MarketDeal, error) `` + StateMinerActiveSectors func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) ([]*miner.SectorOnChainInfo, error) `` + StateMinerAllocated func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (*bitfield.BitField, error) `` + StateMinerAvailableBalance func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (types.BigInt, error) `perm:"read"` + StateMinerCreationDeposit func(p0 context.Context, p1 types.TipSetKey) (types.BigInt, error) `` + StateMinerDeadlines func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) ([]api.Deadline, error) `perm:"read"` + StateMinerFaults func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (bitfield.BitField, error) `` + StateMinerInfo func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (api.MinerInfo, error) `` + StateMinerInitialPledgeForSector func(p0 context.Context, p1 abi.ChainEpoch, p2 abi.SectorSize, p3 uint64, p4 types.TipSetKey) (types.BigInt, error) `` + StateMinerPartitions func(p0 context.Context, p1 address.Address, p2 uint64, p3 types.TipSetKey) ([]api.Partition, error) `` + StateMinerPower func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (*api.MinerPower, error) `perm:"read"` + StateMinerPreCommitDepositForPower func(p0 context.Context, p1 address.Address, p2 miner.SectorPreCommitInfo, p3 types.TipSetKey) (big.Int, error) `` + StateMinerProvingDeadline func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (*dline.Info, error) `` + StateMinerRecoveries func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (bitfield.BitField, error) `` + StateMinerSectorCount func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (api.MinerSectors, error) `` + StateMinerSectors func(p0 context.Context, p1 address.Address, p2 *bitfield.BitField, p3 types.TipSetKey) ([]*miner.SectorOnChainInfo, error) `` + StateNetworkName func(p0 context.Context) (dtypes.NetworkName, error) `` + StateNetworkVersion func(p0 context.Context, p1 types.TipSetKey) (network.Version, error) `` + StateReadState func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (*api.ActorState, error) `` + StateSearchMsg func(p0 context.Context, p1 types.TipSetKey, p2 cid.Cid, p3 abi.ChainEpoch, p4 bool) (*api.MsgLookup, error) `` + StateSectorGetInfo func(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (*miner.SectorOnChainInfo, error) `` + StateSectorPartition func(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (*miner.SectorLocation, error) `` + StateSectorPreCommitInfo func(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (*miner.SectorPreCommitOnChainInfo, error) `` + StateVMCirculatingSupplyInternal func(p0 context.Context, p1 types.TipSetKey) (api.CirculatingSupply, error) `` + StateVerifiedClientStatus func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (*abi.StoragePower, error) `` + StateWaitMsg func(p0 context.Context, p1 cid.Cid, p2 uint64, p3 abi.ChainEpoch, p4 bool) (*api.MsgLookup, error) `perm:"read"` - SyncSubmitBlock func(p0 context.Context, p1 *types.BlockMsg) error `` + + SyncSubmitBlock func(p0 context.Context, p1 *types.BlockMsg) (error) `` + Version func(p0 context.Context) (api.APIVersion, error) `perm:"read"` + WalletBalance func(p0 context.Context, p1 address.Address) (big.Int, error) `` + WalletHas func(p0 context.Context, p1 address.Address) (bool, error) `` + WalletSign func(p0 context.Context, p1 address.Address, p2 []byte) (*crypto.Signature, error) `` + WalletSignMessage func(p0 context.Context, p1 address.Address, p2 *types.Message) (*types.SignedMessage, error) `` -} + + + } type CurioChainRPCStub struct { + } + + + + func (s *CurioStruct) AllocatePieceToSector(p0 context.Context, p1 address.Address, p2 lpiece.PieceDealInfo, p3 int64, p4 url.URL, p5 http.Header) (api.SectorOffset, error) { if s.Internal.AllocatePieceToSector == nil { return *new(api.SectorOffset), ErrNotSupported @@ -247,14 +348,14 @@ func (s *CurioStub) AllocatePieceToSector(p0 context.Context, p1 address.Address return *new(api.SectorOffset), ErrNotSupported } -func (s *CurioStruct) Cordon(p0 context.Context) error { +func (s *CurioStruct) Cordon(p0 context.Context) (error) { if s.Internal.Cordon == nil { return ErrNotSupported } return s.Internal.Cordon(p0) } -func (s *CurioStub) Cordon(p0 context.Context) error { +func (s *CurioStub) Cordon(p0 context.Context) (error) { return ErrNotSupported } @@ -291,47 +392,47 @@ func (s *CurioStub) LogList(p0 context.Context) ([]string, error) { return *new([]string), ErrNotSupported } -func (s *CurioStruct) LogSetLevel(p0 context.Context, p1 string, p2 string) error { +func (s *CurioStruct) LogSetLevel(p0 context.Context, p1 string, p2 string) (error) { if s.Internal.LogSetLevel == nil { return ErrNotSupported } return s.Internal.LogSetLevel(p0, p1, p2) } -func (s *CurioStub) LogSetLevel(p0 context.Context, p1 string, p2 string) error { +func (s *CurioStub) LogSetLevel(p0 context.Context, p1 string, p2 string) (error) { return ErrNotSupported } -func (s *CurioStruct) Shutdown(p0 context.Context) error { +func (s *CurioStruct) Shutdown(p0 context.Context) (error) { if s.Internal.Shutdown == nil { return ErrNotSupported } return s.Internal.Shutdown(p0) } -func (s *CurioStub) Shutdown(p0 context.Context) error { +func (s *CurioStub) Shutdown(p0 context.Context) (error) { return ErrNotSupported } -func (s *CurioStruct) StorageAddLocal(p0 context.Context, p1 string) error { +func (s *CurioStruct) StorageAddLocal(p0 context.Context, p1 string) (error) { if s.Internal.StorageAddLocal == nil { return ErrNotSupported } return s.Internal.StorageAddLocal(p0, p1) } -func (s *CurioStub) StorageAddLocal(p0 context.Context, p1 string) error { +func (s *CurioStub) StorageAddLocal(p0 context.Context, p1 string) (error) { return ErrNotSupported } -func (s *CurioStruct) StorageDetachLocal(p0 context.Context, p1 string) error { +func (s *CurioStruct) StorageDetachLocal(p0 context.Context, p1 string) (error) { if s.Internal.StorageDetachLocal == nil { return ErrNotSupported } return s.Internal.StorageDetachLocal(p0, p1) } -func (s *CurioStub) StorageDetachLocal(p0 context.Context, p1 string) error { +func (s *CurioStub) StorageDetachLocal(p0 context.Context, p1 string) (error) { return ErrNotSupported } @@ -368,14 +469,14 @@ func (s *CurioStub) StorageInfo(p0 context.Context, p1 storiface.ID) (storiface. return *new(storiface.StorageInfo), ErrNotSupported } -func (s *CurioStruct) StorageInit(p0 context.Context, p1 string, p2 storiface.LocalStorageMeta) error { +func (s *CurioStruct) StorageInit(p0 context.Context, p1 string, p2 storiface.LocalStorageMeta) (error) { if s.Internal.StorageInit == nil { return ErrNotSupported } return s.Internal.StorageInit(p0, p1, p2) } -func (s *CurioStub) StorageInit(p0 context.Context, p1 string, p2 storiface.LocalStorageMeta) error { +func (s *CurioStub) StorageInit(p0 context.Context, p1 string, p2 storiface.LocalStorageMeta) (error) { return ErrNotSupported } @@ -401,14 +502,14 @@ func (s *CurioStub) StorageLocal(p0 context.Context) (map[storiface.ID]string, e return *new(map[storiface.ID]string), ErrNotSupported } -func (s *CurioStruct) StorageRedeclare(p0 context.Context, p1 *storiface.ID, p2 bool) error { +func (s *CurioStruct) StorageRedeclare(p0 context.Context, p1 *storiface.ID, p2 bool) (error) { if s.Internal.StorageRedeclare == nil { return ErrNotSupported } return s.Internal.StorageRedeclare(p0, p1, p2) } -func (s *CurioStub) StorageRedeclare(p0 context.Context, p1 *storiface.ID, p2 bool) error { +func (s *CurioStub) StorageRedeclare(p0 context.Context, p1 *storiface.ID, p2 bool) (error) { return ErrNotSupported } @@ -423,14 +524,14 @@ func (s *CurioStub) StorageStat(p0 context.Context, p1 storiface.ID) (fsutil.FsS return *new(fsutil.FsStat), ErrNotSupported } -func (s *CurioStruct) Uncordon(p0 context.Context) error { +func (s *CurioStruct) Uncordon(p0 context.Context) (error) { if s.Internal.Uncordon == nil { return ErrNotSupported } return s.Internal.Uncordon(p0) } -func (s *CurioStub) Uncordon(p0 context.Context) error { +func (s *CurioStub) Uncordon(p0 context.Context) (error) { return ErrNotSupported } @@ -445,6 +546,9 @@ func (s *CurioStub) Version(p0 context.Context) ([]int, error) { return *new([]int), ErrNotSupported } + + + func (s *CurioChainRPCStruct) AuthNew(p0 context.Context, p1 []auth.Permission) ([]byte, error) { if s.Internal.AuthNew == nil { return *new([]byte), ErrNotSupported @@ -544,14 +648,14 @@ func (s *CurioChainRPCStub) ChainNotify(p0 context.Context) (<-chan []*api.HeadC return nil, ErrNotSupported } -func (s *CurioChainRPCStruct) ChainPutObj(p0 context.Context, p1 blocks.Block) error { +func (s *CurioChainRPCStruct) ChainPutObj(p0 context.Context, p1 blocks.Block) (error) { if s.Internal.ChainPutObj == nil { return ErrNotSupported } return s.Internal.ChainPutObj(p0, p1) } -func (s *CurioChainRPCStub) ChainPutObj(p0 context.Context, p1 blocks.Block) error { +func (s *CurioChainRPCStub) ChainPutObj(p0 context.Context, p1 blocks.Block) (error) { return ErrNotSupported } @@ -698,14 +802,14 @@ func (s *CurioChainRPCStub) Session(p0 context.Context) (uuid.UUID, error) { return *new(uuid.UUID), ErrNotSupported } -func (s *CurioChainRPCStruct) Shutdown(p0 context.Context) error { +func (s *CurioChainRPCStruct) Shutdown(p0 context.Context) (error) { if s.Internal.Shutdown == nil { return ErrNotSupported } return s.Internal.Shutdown(p0) } -func (s *CurioChainRPCStub) Shutdown(p0 context.Context) error { +func (s *CurioChainRPCStub) Shutdown(p0 context.Context) (error) { return ErrNotSupported } @@ -1160,14 +1264,14 @@ func (s *CurioChainRPCStub) StateWaitMsg(p0 context.Context, p1 cid.Cid, p2 uint return nil, ErrNotSupported } -func (s *CurioChainRPCStruct) SyncSubmitBlock(p0 context.Context, p1 *types.BlockMsg) error { +func (s *CurioChainRPCStruct) SyncSubmitBlock(p0 context.Context, p1 *types.BlockMsg) (error) { if s.Internal.SyncSubmitBlock == nil { return ErrNotSupported } return s.Internal.SyncSubmitBlock(p0, p1) } -func (s *CurioChainRPCStub) SyncSubmitBlock(p0 context.Context, p1 *types.BlockMsg) error { +func (s *CurioChainRPCStub) SyncSubmitBlock(p0 context.Context, p1 *types.BlockMsg) (error) { return ErrNotSupported } @@ -1226,5 +1330,9 @@ func (s *CurioChainRPCStub) WalletSignMessage(p0 context.Context, p1 address.Add return nil, ErrNotSupported } + + var _ Curio = new(CurioStruct) var _ CurioChainRPC = new(CurioChainRPCStruct) + + diff --git a/deps/config/doc_gen.go b/deps/config/doc_gen.go index d06d3b817..cfbb794ca 100644 --- a/deps/config/doc_gen.go +++ b/deps/config/doc_gen.go @@ -906,7 +906,8 @@ Time duration string (e.g., "1h2m3s") in TOML format. (Default: "5m0s")`, Type: "[]string", Comment: `CORSOrigins specifies the allowed origins for CORS requests. If empty, CORS is disabled. -If not empty, only the specified origins will be allowed for CORS requests This is `, +If not empty, only the specified origins will be allowed for CORS requests. +This is required for third-party UI servers.`, }, { Name: "CSP", diff --git a/deps/config/types.go b/deps/config/types.go index 4b66ecf60..f77e2a4a3 100644 --- a/deps/config/types.go +++ b/deps/config/types.go @@ -864,6 +864,7 @@ type HTTPConfig struct { // CORSOrigins specifies the allowed origins for CORS requests. If empty, CORS is disabled. // If not empty, only the specified origins will be allowed for CORS requests. + // This is required for third-party UI servers. CORSOrigins []string // CSP sets the Content Security Policy for content served via the /piece/ retrieval endpoint. diff --git a/lib/paths/mocks/index.go b/lib/paths/mocks/index.go index 082d22908..110b76818 100644 --- a/lib/paths/mocks/index.go +++ b/lib/paths/mocks/index.go @@ -8,14 +8,11 @@ import ( context "context" reflect "reflect" - gomock "github.com/golang/mock/gomock" - - abi "github.com/filecoin-project/go-state-types/abi" - paths "github.com/filecoin-project/curio/lib/paths" storiface "github.com/filecoin-project/curio/lib/storiface" - + abi "github.com/filecoin-project/go-state-types/abi" fsutil "github.com/filecoin-project/lotus/storage/sealer/fsutil" + gomock "github.com/golang/mock/gomock" ) // MockSectorIndex is a mock of SectorIndex interface. diff --git a/lib/paths/mocks/pf.go b/lib/paths/mocks/pf.go index 072e47b2e..ee181dcba 100644 --- a/lib/paths/mocks/pf.go +++ b/lib/paths/mocks/pf.go @@ -8,12 +8,10 @@ import ( io "io" reflect "reflect" - gomock "github.com/golang/mock/gomock" - - abi "github.com/filecoin-project/go-state-types/abi" - partialfile "github.com/filecoin-project/curio/lib/partialfile" storiface "github.com/filecoin-project/curio/lib/storiface" + abi "github.com/filecoin-project/go-state-types/abi" + gomock "github.com/golang/mock/gomock" ) // MockPartialFileHandler is a mock of PartialFileHandler interface. diff --git a/lib/paths/mocks/store.go b/lib/paths/mocks/store.go index e7c3c184c..816a392af 100644 --- a/lib/paths/mocks/store.go +++ b/lib/paths/mocks/store.go @@ -8,14 +8,11 @@ import ( context "context" reflect "reflect" - gomock "github.com/golang/mock/gomock" - cid "github.com/ipfs/go-cid" - - abi "github.com/filecoin-project/go-state-types/abi" - storiface "github.com/filecoin-project/curio/lib/storiface" - + abi "github.com/filecoin-project/go-state-types/abi" fsutil "github.com/filecoin-project/lotus/storage/sealer/fsutil" + gomock "github.com/golang/mock/gomock" + cid "github.com/ipfs/go-cid" ) // MockStore is a mock of Store interface. From ab5e8c791970d609a281bace0acc47a9107d0960 Mon Sep 17 00:00:00 2001 From: "Andrew Jackson (Ajax)" Date: Thu, 25 Sep 2025 17:01:15 -0500 Subject: [PATCH 07/11] fiximports --- api/proxy_gen.go | 206 ++++++++++----------------------------- lib/paths/mocks/index.go | 7 +- lib/paths/mocks/pf.go | 6 +- lib/paths/mocks/store.go | 9 +- 4 files changed, 64 insertions(+), 164 deletions(-) diff --git a/api/proxy_gen.go b/api/proxy_gen.go index 7737717e1..114481675 100644 --- a/api/proxy_gen.go +++ b/api/proxy_gen.go @@ -4,8 +4,16 @@ package api import ( "context" - ltypes "github.com/filecoin-project/curio/api/types" - "github.com/filecoin-project/curio/lib/storiface" + "net/http" + "net/url" + "reflect" + + "github.com/google/uuid" + blocks "github.com/ipfs/go-block-format" + "github.com/ipfs/go-cid" + "github.com/multiformats/go-multihash" + "golang.org/x/xerrors" + "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-bitfield" "github.com/filecoin-project/go-jsonrpc/auth" @@ -15,328 +23,219 @@ import ( "github.com/filecoin-project/go-state-types/crypto" "github.com/filecoin-project/go-state-types/dline" "github.com/filecoin-project/go-state-types/network" + + ltypes "github.com/filecoin-project/curio/api/types" + "github.com/filecoin-project/curio/lib/storiface" + "github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/chain/actors/builtin/miner" "github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/node/modules/dtypes" lpiece "github.com/filecoin-project/lotus/storage/pipeline/piece" "github.com/filecoin-project/lotus/storage/sealer/fsutil" - "github.com/google/uuid" - blocks "github.com/ipfs/go-block-format" - "github.com/ipfs/go-cid" - "github.com/multiformats/go-multihash" - "net/http" - "net/url" - "reflect" - - "golang.org/x/xerrors" ) - var _ = reflect.TypeOf([]byte(nil)) var ErrNotSupported = xerrors.New("method not supported") - type CurioStruct struct { - Internal CurioMethods } type CurioMethods struct { - AllocatePieceToSector func(p0 context.Context, p1 address.Address, p2 lpiece.PieceDealInfo, p3 int64, p4 url.URL, p5 http.Header) (api.SectorOffset, error) `perm:"write"` - - Cordon func(p0 context.Context) (error) `perm:"admin"` - + Cordon func(p0 context.Context) error `perm:"admin"` IndexSamples func(p0 context.Context, p1 cid.Cid) ([]multihash.Multihash, error) `perm:"admin"` - Info func(p0 context.Context) (*ltypes.NodeInfo, error) `perm:"read"` - LogList func(p0 context.Context) ([]string, error) `perm:"read"` + LogSetLevel func(p0 context.Context, p1 string, p2 string) error `perm:"admin"` - LogSetLevel func(p0 context.Context, p1 string, p2 string) (error) `perm:"admin"` - - - Shutdown func(p0 context.Context) (error) `perm:"admin"` + Shutdown func(p0 context.Context) error `perm:"admin"` + StorageAddLocal func(p0 context.Context, p1 string) error `perm:"admin"` - StorageAddLocal func(p0 context.Context, p1 string) (error) `perm:"admin"` - - - StorageDetachLocal func(p0 context.Context, p1 string) (error) `perm:"admin"` - + StorageDetachLocal func(p0 context.Context, p1 string) error `perm:"admin"` StorageFindSector func(p0 context.Context, p1 abi.SectorID, p2 storiface.SectorFileType, p3 abi.SectorSize, p4 bool) ([]storiface.SectorStorageInfo, error) `perm:"admin"` - StorageGenerateVanillaProof func(p0 context.Context, p1 address.Address, p2 abi.SectorNumber) ([]byte, error) `perm:"admin"` - StorageInfo func(p0 context.Context, p1 storiface.ID) (storiface.StorageInfo, error) `perm:"admin"` - - StorageInit func(p0 context.Context, p1 string, p2 storiface.LocalStorageMeta) (error) `perm:"admin"` - + StorageInit func(p0 context.Context, p1 string, p2 storiface.LocalStorageMeta) error `perm:"admin"` StorageList func(p0 context.Context) (map[storiface.ID][]storiface.Decl, error) `perm:"admin"` - StorageLocal func(p0 context.Context) (map[storiface.ID]string, error) `perm:"admin"` - - StorageRedeclare func(p0 context.Context, p1 *storiface.ID, p2 bool) (error) `perm:"admin"` - + StorageRedeclare func(p0 context.Context, p1 *storiface.ID, p2 bool) error `perm:"admin"` StorageStat func(p0 context.Context, p1 storiface.ID) (fsutil.FsStat, error) `perm:"admin"` - - Uncordon func(p0 context.Context) (error) `perm:"admin"` - + Uncordon func(p0 context.Context) error `perm:"admin"` Version func(p0 context.Context) ([]int, error) `perm:"admin"` - - - } +} type CurioStub struct { - } type CurioChainRPCStruct struct { - Internal CurioChainRPCMethods } type CurioChainRPCMethods struct { - AuthNew func(p0 context.Context, p1 []auth.Permission) ([]byte, error) `perm:"admin"` - AuthVerify func(p0 context.Context, p1 string) ([]auth.Permission, error) `perm:"read"` - ChainGetMessage func(p0 context.Context, p1 cid.Cid) (*types.Message, error) `` - ChainGetTipSet func(p0 context.Context, p1 types.TipSetKey) (*types.TipSet, error) `` - ChainGetTipSetAfterHeight func(p0 context.Context, p1 abi.ChainEpoch, p2 types.TipSetKey) (*types.TipSet, error) `` - ChainGetTipSetByHeight func(p0 context.Context, p1 abi.ChainEpoch, p2 types.TipSetKey) (*types.TipSet, error) `` - ChainHasObj func(p0 context.Context, p1 cid.Cid) (bool, error) `` - ChainHead func(p0 context.Context) (*types.TipSet, error) `` - ChainNotify func(p0 context.Context) (<-chan []*api.HeadChange, error) `` - - ChainPutObj func(p0 context.Context, p1 blocks.Block) (error) `` - + ChainPutObj func(p0 context.Context, p1 blocks.Block) error `` ChainReadObj func(p0 context.Context, p1 cid.Cid) ([]byte, error) `` - ChainTipSetWeight func(p0 context.Context, p1 types.TipSetKey) (types.BigInt, error) `` - GasEstimateFeeCap func(p0 context.Context, p1 *types.Message, p2 int64, p3 types.TipSetKey) (types.BigInt, error) `` - GasEstimateGasPremium func(p0 context.Context, p1 uint64, p2 address.Address, p3 int64, p4 types.TipSetKey) (types.BigInt, error) `` - GasEstimateMessageGas func(p0 context.Context, p1 *types.Message, p2 *api.MessageSendSpec, p3 types.TipSetKey) (*types.Message, error) `` - MarketAddBalance func(p0 context.Context, p1 address.Address, p2 address.Address, p3 types.BigInt) (cid.Cid, error) `` - MinerCreateBlock func(p0 context.Context, p1 *api.BlockTemplate) (*types.BlockMsg, error) `` - MinerGetBaseInfo func(p0 context.Context, p1 address.Address, p2 abi.ChainEpoch, p3 types.TipSetKey) (*api.MiningBaseInfo, error) `` - MpoolGetNonce func(p0 context.Context, p1 address.Address) (uint64, error) `` - MpoolPush func(p0 context.Context, p1 *types.SignedMessage) (cid.Cid, error) `` - MpoolPushMessage func(p0 context.Context, p1 *types.Message, p2 *api.MessageSendSpec) (*types.SignedMessage, error) `` - MpoolSelect func(p0 context.Context, p1 types.TipSetKey, p2 float64) ([]*types.SignedMessage, error) `` - Session func(p0 context.Context) (uuid.UUID, error) `perm:"read"` - - Shutdown func(p0 context.Context) (error) `perm:"admin"` - + Shutdown func(p0 context.Context) error `perm:"admin"` StateAccountKey func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (address.Address, error) `` - StateCall func(p0 context.Context, p1 *types.Message, p2 types.TipSetKey) (*api.InvocResult, error) `` - StateCirculatingSupply func(p0 context.Context, p1 types.TipSetKey) (big.Int, error) `` - StateDealProviderCollateralBounds func(p0 context.Context, p1 abi.PaddedPieceSize, p2 bool, p3 types.TipSetKey) (api.DealCollateralBounds, error) `` - StateGetActor func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (*types.Actor, error) `` - StateGetAllocation func(p0 context.Context, p1 address.Address, p2 verifregtypes.AllocationId, p3 types.TipSetKey) (*verifregtypes.Allocation, error) `` - StateGetAllocationForPendingDeal func(p0 context.Context, p1 abi.DealID, p2 types.TipSetKey) (*verifregtypes.Allocation, error) `` - StateGetAllocationIdForPendingDeal func(p0 context.Context, p1 abi.DealID, p2 types.TipSetKey) (verifregtypes.AllocationId, error) `` - StateGetBeaconEntry func(p0 context.Context, p1 abi.ChainEpoch) (*types.BeaconEntry, error) `` - StateGetRandomnessFromBeacon func(p0 context.Context, p1 crypto.DomainSeparationTag, p2 abi.ChainEpoch, p3 []byte, p4 types.TipSetKey) (abi.Randomness, error) `` - StateGetRandomnessFromTickets func(p0 context.Context, p1 crypto.DomainSeparationTag, p2 abi.ChainEpoch, p3 []byte, p4 types.TipSetKey) (abi.Randomness, error) `` - StateListMessages func(p0 context.Context, p1 *api.MessageMatch, p2 types.TipSetKey, p3 abi.ChainEpoch) ([]cid.Cid, error) `` - StateListMiners func(p0 context.Context, p1 types.TipSetKey) ([]address.Address, error) `` - StateLookupID func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (address.Address, error) `` - StateMarketBalance func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (api.MarketBalance, error) `` - StateMarketStorageDeal func(p0 context.Context, p1 abi.DealID, p2 types.TipSetKey) (*api.MarketDeal, error) `` - StateMinerActiveSectors func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) ([]*miner.SectorOnChainInfo, error) `` - StateMinerAllocated func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (*bitfield.BitField, error) `` - StateMinerAvailableBalance func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (types.BigInt, error) `perm:"read"` - StateMinerCreationDeposit func(p0 context.Context, p1 types.TipSetKey) (types.BigInt, error) `` - StateMinerDeadlines func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) ([]api.Deadline, error) `perm:"read"` - StateMinerFaults func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (bitfield.BitField, error) `` - StateMinerInfo func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (api.MinerInfo, error) `` - StateMinerInitialPledgeForSector func(p0 context.Context, p1 abi.ChainEpoch, p2 abi.SectorSize, p3 uint64, p4 types.TipSetKey) (types.BigInt, error) `` - StateMinerPartitions func(p0 context.Context, p1 address.Address, p2 uint64, p3 types.TipSetKey) ([]api.Partition, error) `` - StateMinerPower func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (*api.MinerPower, error) `perm:"read"` - StateMinerPreCommitDepositForPower func(p0 context.Context, p1 address.Address, p2 miner.SectorPreCommitInfo, p3 types.TipSetKey) (big.Int, error) `` - StateMinerProvingDeadline func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (*dline.Info, error) `` - StateMinerRecoveries func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (bitfield.BitField, error) `` - StateMinerSectorCount func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (api.MinerSectors, error) `` - StateMinerSectors func(p0 context.Context, p1 address.Address, p2 *bitfield.BitField, p3 types.TipSetKey) ([]*miner.SectorOnChainInfo, error) `` - StateNetworkName func(p0 context.Context) (dtypes.NetworkName, error) `` - StateNetworkVersion func(p0 context.Context, p1 types.TipSetKey) (network.Version, error) `` - StateReadState func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (*api.ActorState, error) `` - StateSearchMsg func(p0 context.Context, p1 types.TipSetKey, p2 cid.Cid, p3 abi.ChainEpoch, p4 bool) (*api.MsgLookup, error) `` - StateSectorGetInfo func(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (*miner.SectorOnChainInfo, error) `` - StateSectorPartition func(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (*miner.SectorLocation, error) `` - StateSectorPreCommitInfo func(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (*miner.SectorPreCommitOnChainInfo, error) `` - StateVMCirculatingSupplyInternal func(p0 context.Context, p1 types.TipSetKey) (api.CirculatingSupply, error) `` - StateVerifiedClientStatus func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (*abi.StoragePower, error) `` - StateWaitMsg func(p0 context.Context, p1 cid.Cid, p2 uint64, p3 abi.ChainEpoch, p4 bool) (*api.MsgLookup, error) `perm:"read"` - - SyncSubmitBlock func(p0 context.Context, p1 *types.BlockMsg) (error) `` - + SyncSubmitBlock func(p0 context.Context, p1 *types.BlockMsg) error `` Version func(p0 context.Context) (api.APIVersion, error) `perm:"read"` - WalletBalance func(p0 context.Context, p1 address.Address) (big.Int, error) `` - WalletHas func(p0 context.Context, p1 address.Address) (bool, error) `` - WalletSign func(p0 context.Context, p1 address.Address, p2 []byte) (*crypto.Signature, error) `` - WalletSignMessage func(p0 context.Context, p1 address.Address, p2 *types.Message) (*types.SignedMessage, error) `` - - - } +} type CurioChainRPCStub struct { - } - - - - func (s *CurioStruct) AllocatePieceToSector(p0 context.Context, p1 address.Address, p2 lpiece.PieceDealInfo, p3 int64, p4 url.URL, p5 http.Header) (api.SectorOffset, error) { if s.Internal.AllocatePieceToSector == nil { return *new(api.SectorOffset), ErrNotSupported @@ -348,14 +247,14 @@ func (s *CurioStub) AllocatePieceToSector(p0 context.Context, p1 address.Address return *new(api.SectorOffset), ErrNotSupported } -func (s *CurioStruct) Cordon(p0 context.Context) (error) { +func (s *CurioStruct) Cordon(p0 context.Context) error { if s.Internal.Cordon == nil { return ErrNotSupported } return s.Internal.Cordon(p0) } -func (s *CurioStub) Cordon(p0 context.Context) (error) { +func (s *CurioStub) Cordon(p0 context.Context) error { return ErrNotSupported } @@ -392,47 +291,47 @@ func (s *CurioStub) LogList(p0 context.Context) ([]string, error) { return *new([]string), ErrNotSupported } -func (s *CurioStruct) LogSetLevel(p0 context.Context, p1 string, p2 string) (error) { +func (s *CurioStruct) LogSetLevel(p0 context.Context, p1 string, p2 string) error { if s.Internal.LogSetLevel == nil { return ErrNotSupported } return s.Internal.LogSetLevel(p0, p1, p2) } -func (s *CurioStub) LogSetLevel(p0 context.Context, p1 string, p2 string) (error) { +func (s *CurioStub) LogSetLevel(p0 context.Context, p1 string, p2 string) error { return ErrNotSupported } -func (s *CurioStruct) Shutdown(p0 context.Context) (error) { +func (s *CurioStruct) Shutdown(p0 context.Context) error { if s.Internal.Shutdown == nil { return ErrNotSupported } return s.Internal.Shutdown(p0) } -func (s *CurioStub) Shutdown(p0 context.Context) (error) { +func (s *CurioStub) Shutdown(p0 context.Context) error { return ErrNotSupported } -func (s *CurioStruct) StorageAddLocal(p0 context.Context, p1 string) (error) { +func (s *CurioStruct) StorageAddLocal(p0 context.Context, p1 string) error { if s.Internal.StorageAddLocal == nil { return ErrNotSupported } return s.Internal.StorageAddLocal(p0, p1) } -func (s *CurioStub) StorageAddLocal(p0 context.Context, p1 string) (error) { +func (s *CurioStub) StorageAddLocal(p0 context.Context, p1 string) error { return ErrNotSupported } -func (s *CurioStruct) StorageDetachLocal(p0 context.Context, p1 string) (error) { +func (s *CurioStruct) StorageDetachLocal(p0 context.Context, p1 string) error { if s.Internal.StorageDetachLocal == nil { return ErrNotSupported } return s.Internal.StorageDetachLocal(p0, p1) } -func (s *CurioStub) StorageDetachLocal(p0 context.Context, p1 string) (error) { +func (s *CurioStub) StorageDetachLocal(p0 context.Context, p1 string) error { return ErrNotSupported } @@ -469,14 +368,14 @@ func (s *CurioStub) StorageInfo(p0 context.Context, p1 storiface.ID) (storiface. return *new(storiface.StorageInfo), ErrNotSupported } -func (s *CurioStruct) StorageInit(p0 context.Context, p1 string, p2 storiface.LocalStorageMeta) (error) { +func (s *CurioStruct) StorageInit(p0 context.Context, p1 string, p2 storiface.LocalStorageMeta) error { if s.Internal.StorageInit == nil { return ErrNotSupported } return s.Internal.StorageInit(p0, p1, p2) } -func (s *CurioStub) StorageInit(p0 context.Context, p1 string, p2 storiface.LocalStorageMeta) (error) { +func (s *CurioStub) StorageInit(p0 context.Context, p1 string, p2 storiface.LocalStorageMeta) error { return ErrNotSupported } @@ -502,14 +401,14 @@ func (s *CurioStub) StorageLocal(p0 context.Context) (map[storiface.ID]string, e return *new(map[storiface.ID]string), ErrNotSupported } -func (s *CurioStruct) StorageRedeclare(p0 context.Context, p1 *storiface.ID, p2 bool) (error) { +func (s *CurioStruct) StorageRedeclare(p0 context.Context, p1 *storiface.ID, p2 bool) error { if s.Internal.StorageRedeclare == nil { return ErrNotSupported } return s.Internal.StorageRedeclare(p0, p1, p2) } -func (s *CurioStub) StorageRedeclare(p0 context.Context, p1 *storiface.ID, p2 bool) (error) { +func (s *CurioStub) StorageRedeclare(p0 context.Context, p1 *storiface.ID, p2 bool) error { return ErrNotSupported } @@ -524,14 +423,14 @@ func (s *CurioStub) StorageStat(p0 context.Context, p1 storiface.ID) (fsutil.FsS return *new(fsutil.FsStat), ErrNotSupported } -func (s *CurioStruct) Uncordon(p0 context.Context) (error) { +func (s *CurioStruct) Uncordon(p0 context.Context) error { if s.Internal.Uncordon == nil { return ErrNotSupported } return s.Internal.Uncordon(p0) } -func (s *CurioStub) Uncordon(p0 context.Context) (error) { +func (s *CurioStub) Uncordon(p0 context.Context) error { return ErrNotSupported } @@ -546,9 +445,6 @@ func (s *CurioStub) Version(p0 context.Context) ([]int, error) { return *new([]int), ErrNotSupported } - - - func (s *CurioChainRPCStruct) AuthNew(p0 context.Context, p1 []auth.Permission) ([]byte, error) { if s.Internal.AuthNew == nil { return *new([]byte), ErrNotSupported @@ -648,14 +544,14 @@ func (s *CurioChainRPCStub) ChainNotify(p0 context.Context) (<-chan []*api.HeadC return nil, ErrNotSupported } -func (s *CurioChainRPCStruct) ChainPutObj(p0 context.Context, p1 blocks.Block) (error) { +func (s *CurioChainRPCStruct) ChainPutObj(p0 context.Context, p1 blocks.Block) error { if s.Internal.ChainPutObj == nil { return ErrNotSupported } return s.Internal.ChainPutObj(p0, p1) } -func (s *CurioChainRPCStub) ChainPutObj(p0 context.Context, p1 blocks.Block) (error) { +func (s *CurioChainRPCStub) ChainPutObj(p0 context.Context, p1 blocks.Block) error { return ErrNotSupported } @@ -802,14 +698,14 @@ func (s *CurioChainRPCStub) Session(p0 context.Context) (uuid.UUID, error) { return *new(uuid.UUID), ErrNotSupported } -func (s *CurioChainRPCStruct) Shutdown(p0 context.Context) (error) { +func (s *CurioChainRPCStruct) Shutdown(p0 context.Context) error { if s.Internal.Shutdown == nil { return ErrNotSupported } return s.Internal.Shutdown(p0) } -func (s *CurioChainRPCStub) Shutdown(p0 context.Context) (error) { +func (s *CurioChainRPCStub) Shutdown(p0 context.Context) error { return ErrNotSupported } @@ -1264,14 +1160,14 @@ func (s *CurioChainRPCStub) StateWaitMsg(p0 context.Context, p1 cid.Cid, p2 uint return nil, ErrNotSupported } -func (s *CurioChainRPCStruct) SyncSubmitBlock(p0 context.Context, p1 *types.BlockMsg) (error) { +func (s *CurioChainRPCStruct) SyncSubmitBlock(p0 context.Context, p1 *types.BlockMsg) error { if s.Internal.SyncSubmitBlock == nil { return ErrNotSupported } return s.Internal.SyncSubmitBlock(p0, p1) } -func (s *CurioChainRPCStub) SyncSubmitBlock(p0 context.Context, p1 *types.BlockMsg) (error) { +func (s *CurioChainRPCStub) SyncSubmitBlock(p0 context.Context, p1 *types.BlockMsg) error { return ErrNotSupported } @@ -1330,9 +1226,5 @@ func (s *CurioChainRPCStub) WalletSignMessage(p0 context.Context, p1 address.Add return nil, ErrNotSupported } - - var _ Curio = new(CurioStruct) var _ CurioChainRPC = new(CurioChainRPCStruct) - - diff --git a/lib/paths/mocks/index.go b/lib/paths/mocks/index.go index 110b76818..082d22908 100644 --- a/lib/paths/mocks/index.go +++ b/lib/paths/mocks/index.go @@ -8,11 +8,14 @@ import ( context "context" reflect "reflect" + gomock "github.com/golang/mock/gomock" + + abi "github.com/filecoin-project/go-state-types/abi" + paths "github.com/filecoin-project/curio/lib/paths" storiface "github.com/filecoin-project/curio/lib/storiface" - abi "github.com/filecoin-project/go-state-types/abi" + fsutil "github.com/filecoin-project/lotus/storage/sealer/fsutil" - gomock "github.com/golang/mock/gomock" ) // MockSectorIndex is a mock of SectorIndex interface. diff --git a/lib/paths/mocks/pf.go b/lib/paths/mocks/pf.go index ee181dcba..072e47b2e 100644 --- a/lib/paths/mocks/pf.go +++ b/lib/paths/mocks/pf.go @@ -8,10 +8,12 @@ import ( io "io" reflect "reflect" + gomock "github.com/golang/mock/gomock" + + abi "github.com/filecoin-project/go-state-types/abi" + partialfile "github.com/filecoin-project/curio/lib/partialfile" storiface "github.com/filecoin-project/curio/lib/storiface" - abi "github.com/filecoin-project/go-state-types/abi" - gomock "github.com/golang/mock/gomock" ) // MockPartialFileHandler is a mock of PartialFileHandler interface. diff --git a/lib/paths/mocks/store.go b/lib/paths/mocks/store.go index 816a392af..e7c3c184c 100644 --- a/lib/paths/mocks/store.go +++ b/lib/paths/mocks/store.go @@ -8,11 +8,14 @@ import ( context "context" reflect "reflect" - storiface "github.com/filecoin-project/curio/lib/storiface" - abi "github.com/filecoin-project/go-state-types/abi" - fsutil "github.com/filecoin-project/lotus/storage/sealer/fsutil" gomock "github.com/golang/mock/gomock" cid "github.com/ipfs/go-cid" + + abi "github.com/filecoin-project/go-state-types/abi" + + storiface "github.com/filecoin-project/curio/lib/storiface" + + fsutil "github.com/filecoin-project/lotus/storage/sealer/fsutil" ) // MockStore is a mock of Store interface. From 262259c1edde2aeab5c420b35d9b404f2723d323 Mon Sep 17 00:00:00 2001 From: "Andrew Jackson (Ajax)" Date: Thu, 25 Sep 2025 17:27:10 -0500 Subject: [PATCH 08/11] fixed --- documentation/en/configuration/default-curio-configuration.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/documentation/en/configuration/default-curio-configuration.md b/documentation/en/configuration/default-curio-configuration.md index 879191453..26388e888 100644 --- a/documentation/en/configuration/default-curio-configuration.md +++ b/documentation/en/configuration/default-curio-configuration.md @@ -559,7 +559,8 @@ description: The default curio configuration #ReadHeaderTimeout = "5s" # CORSOrigins specifies the allowed origins for CORS requests. If empty, CORS is disabled. - # If not empty, only the specified origins will be allowed for CORS requests. This is required for third-party UI servers. + # If not empty, only the specified origins will be allowed for CORS requests. + # This is required for third-party UI servers. # # type: []string #CORSOrigins = [] From 7d86961850fb353433e6a25f7c5f38c15b95b33b Mon Sep 17 00:00:00 2001 From: "Andrew Jackson (Ajax)" Date: Thu, 25 Sep 2025 17:41:01 -0500 Subject: [PATCH 09/11] 2 --- documentation/en/configuration/default-curio-configuration.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/documentation/en/configuration/default-curio-configuration.md b/documentation/en/configuration/default-curio-configuration.md index 26388e888..935d4210b 100644 --- a/documentation/en/configuration/default-curio-configuration.md +++ b/documentation/en/configuration/default-curio-configuration.md @@ -559,7 +559,7 @@ description: The default curio configuration #ReadHeaderTimeout = "5s" # CORSOrigins specifies the allowed origins for CORS requests. If empty, CORS is disabled. - # If not empty, only the specified origins will be allowed for CORS requests. + # If not empty, only the specified origins will be allowed for CORS requests. # This is required for third-party UI servers. # # type: []string From 021835970c418187eac9dcd7eb1b425285cd2b51 Mon Sep 17 00:00:00 2001 From: "Andrew Jackson (Ajax)" Date: Fri, 26 Sep 2025 17:50:36 -0500 Subject: [PATCH 10/11] cors allowed for market --- cuhttp/server.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/cuhttp/server.go b/cuhttp/server.go index ff61e724c..83aaac2b3 100644 --- a/cuhttp/server.go +++ b/cuhttp/server.go @@ -140,6 +140,7 @@ type ServiceDeps struct { DealMarket *storage_market.CurioStorageDealMarket } +// This starts the public-facing server for market calls. func StartHTTPServer(ctx context.Context, d *deps.Deps, sd *ServiceDeps) error { cfg := d.Cfg.HTTP @@ -152,11 +153,7 @@ func StartHTTPServer(ctx context.Context, d *deps.Deps, sd *ServiceDeps) error { chiRouter.Use(middleware.Recoverer) chiRouter.Use(handlers.ProxyHeaders) // Handle reverse proxy headers like X-Forwarded-For chiRouter.Use(secureHeaders(cfg.CSP)) - chiRouter.Use(corsHeaders) - - if len(cfg.CORSOrigins) > 0 { - chiRouter.Use(handlers.CORS(handlers.AllowedOrigins(cfg.CORSOrigins))) - } + chiRouter.Use(corsHeaders) // allows market calls from other domains // Set up the compression middleware with custom compression levels compressionMw, err := compressionMiddleware(&cfg.CompressionLevels) From 6a0c76278e823cd20eade634a9d72cc276d73a52 Mon Sep 17 00:00:00 2001 From: "Andrew Jackson (Ajax)" Date: Thu, 9 Oct 2025 17:19:21 -0400 Subject: [PATCH 11/11] docs --- deps/config/doc_gen.go | 5 +++-- deps/config/types.go | 3 ++- .../en/configuration/default-curio-configuration.md | 3 ++- market/mk20/http/docs.go | 1 + market/mk20/http/swagger.json | 1 + market/mk20/http/swagger.yaml | 1 + 6 files changed, 10 insertions(+), 4 deletions(-) diff --git a/deps/config/doc_gen.go b/deps/config/doc_gen.go index cfbb794ca..b823094fb 100644 --- a/deps/config/doc_gen.go +++ b/deps/config/doc_gen.go @@ -905,9 +905,10 @@ Time duration string (e.g., "1h2m3s") in TOML format. (Default: "5m0s")`, Name: "CORSOrigins", Type: "[]string", - Comment: `CORSOrigins specifies the allowed origins for CORS requests. If empty, CORS is disabled. + Comment: `CORSOrigins specifies the allowed origins for CORS requests to the Curio admin UI. If empty, CORS is disabled. If not empty, only the specified origins will be allowed for CORS requests. -This is required for third-party UI servers.`, +This is required for third-party UI servers. +"*" allows everyone, it's best to specify the UI servers' hostname.`, }, { Name: "CSP", diff --git a/deps/config/types.go b/deps/config/types.go index f77e2a4a3..9210bc261 100644 --- a/deps/config/types.go +++ b/deps/config/types.go @@ -862,9 +862,10 @@ type HTTPConfig struct { // Time duration string (e.g., "1h2m3s") in TOML format. (Default: "5m0s") ReadHeaderTimeout time.Duration - // CORSOrigins specifies the allowed origins for CORS requests. If empty, CORS is disabled. + // CORSOrigins specifies the allowed origins for CORS requests to the Curio admin UI. If empty, CORS is disabled. // If not empty, only the specified origins will be allowed for CORS requests. // This is required for third-party UI servers. + // "*" allows everyone, it's best to specify the UI servers' hostname. CORSOrigins []string // CSP sets the Content Security Policy for content served via the /piece/ retrieval endpoint. diff --git a/documentation/en/configuration/default-curio-configuration.md b/documentation/en/configuration/default-curio-configuration.md index 935d4210b..cda1de15b 100644 --- a/documentation/en/configuration/default-curio-configuration.md +++ b/documentation/en/configuration/default-curio-configuration.md @@ -558,9 +558,10 @@ description: The default curio configuration # type: time.Duration #ReadHeaderTimeout = "5s" - # CORSOrigins specifies the allowed origins for CORS requests. If empty, CORS is disabled. + # CORSOrigins specifies the allowed origins for CORS requests to the Curio admin UI. If empty, CORS is disabled. # If not empty, only the specified origins will be allowed for CORS requests. # This is required for third-party UI servers. + # "*" allows everyone, it's best to specify the UI servers' hostname. # # type: []string #CORSOrigins = [] diff --git a/market/mk20/http/docs.go b/market/mk20/http/docs.go index c64e6a6bb..52d9e24eb 100644 --- a/market/mk20/http/docs.go +++ b/market/mk20/http/docs.go @@ -853,6 +853,7 @@ const docTemplate = `{ }, "github_com_filecoin-project_go-state-types_builtin_v16_verifreg.AllocationId": { "type": "integer", + "format": "int64", "enum": [ 0 ], diff --git a/market/mk20/http/swagger.json b/market/mk20/http/swagger.json index ef9c84c1d..034c867af 100644 --- a/market/mk20/http/swagger.json +++ b/market/mk20/http/swagger.json @@ -844,6 +844,7 @@ }, "github_com_filecoin-project_go-state-types_builtin_v16_verifreg.AllocationId": { "type": "integer", + "format": "int64", "enum": [ 0 ], diff --git a/market/mk20/http/swagger.yaml b/market/mk20/http/swagger.yaml index 6744e648f..5ef589b0a 100644 --- a/market/mk20/http/swagger.yaml +++ b/market/mk20/http/swagger.yaml @@ -4,6 +4,7 @@ definitions: github_com_filecoin-project_go-state-types_builtin_v16_verifreg.AllocationId: enum: - 0 + format: int64 type: integer x-enum-varnames: - NoAllocationID