Skip to content

Commit

Permalink
rebase v1.24
Browse files Browse the repository at this point in the history
fix: update docker

fix: genesis new command

feat: add network info command

fix: permission check

feat: set genesis block timestamp

feat: set BlockDelaySecs by env tag

fix: add UpgradeWatermelonFixHeight and UpgradeWatermelonFix2Height to force
  • Loading branch information
simlecode committed Nov 23, 2023
1 parent 79bb2b1 commit a8312f7
Show file tree
Hide file tree
Showing 11 changed files with 320 additions and 248 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,7 @@ dist/
# in dirty git state if removed from the docker context
!extern/filecoin-ffi/rust/filecoin.pc
!extern/test-vectors

localnet.json

devgen.car
146 changes: 19 additions & 127 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,136 +1,28 @@
#####################################
FROM golang:1.20.7-bullseye AS lotus-builder
MAINTAINER Lotus Development Team
ARG RUNTIME_TAG=v1.14.0

RUN apt-get update && apt-get install -y ca-certificates build-essential clang ocl-icd-opencl-dev ocl-icd-libopencl1 jq libhwloc-dev
FROM filvenus/venus-buildenv:v1.14.0 AS buildenv

ENV XDG_CACHE_HOME="/tmp"
WORKDIR /build

### taken from https://github.com/rust-lang/docker-rust/blob/master/1.63.0/buster/Dockerfile
ENV RUSTUP_HOME=/usr/local/rustup \
CARGO_HOME=/usr/local/cargo \
PATH=/usr/local/cargo/bin:$PATH \
RUST_VERSION=1.63.0
ENV GOPROXY="https://goproxy.cn,direct"

RUN set -eux; \
dpkgArch="$(dpkg --print-architecture)"; \
case "${dpkgArch##*-}" in \
amd64) rustArch='x86_64-unknown-linux-gnu'; rustupSha256='5cc9ffd1026e82e7fb2eec2121ad71f4b0f044e88bca39207b3f6b769aaa799c' ;; \
arm64) rustArch='aarch64-unknown-linux-gnu'; rustupSha256='e189948e396d47254103a49c987e7fb0e5dd8e34b200aa4481ecc4b8e41fb929' ;; \
*) echo >&2 "unsupported architecture: ${dpkgArch}"; exit 1 ;; \
esac; \
url="https://static.rust-lang.org/rustup/archive/1.25.1/${rustArch}/rustup-init"; \
wget "$url"; \
echo "${rustupSha256} *rustup-init" | sha256sum -c -; \
chmod +x rustup-init; \
./rustup-init -y --no-modify-path --profile minimal --default-toolchain $RUST_VERSION --default-host ${rustArch}; \
rm rustup-init; \
chmod -R a+w $RUSTUP_HOME $CARGO_HOME; \
rustup --version; \
cargo --version; \
rustc --version;
COPY ./go.mod /build/
COPY ./exter[n] ./go.mod /build/extern/
RUN go mod download

COPY ./ /opt/filecoin
WORKDIR /opt/filecoin
COPY . /build
RUN make dist-clean
RUN make deps
RUN make force

RUN scripts/docker-git-state-check.sh
FROM filvenus/venus-runtime:${RUNTIME_TAG}

### make configurable filecoin-ffi build
ARG FFI_BUILD_FROM_SOURCE=0
ENV FFI_BUILD_FROM_SOURCE=${FFI_BUILD_FROM_SOURCE}
ARG BUILD_TARGET=
ENV VENUS_COMPONENT=${BUILD_TARGET}

RUN make clean deps
# copy the app from build env
COPY --from=buildenv /build/lotus /lotus
COPY --from=buildenv /build/lotus-miner /lotus-miner
COPY --from=buildenv /build/lotus-seed /lotus-seed

ARG RUSTFLAGS=""
ARG GOFLAGS=""

RUN make buildall

#####################################
FROM ubuntu:20.04 AS lotus-base
MAINTAINER Lotus Development Team

# Base resources
COPY --from=lotus-builder /etc/ssl/certs /etc/ssl/certs
COPY --from=lotus-builder /lib/*/libdl.so.2 /lib/
COPY --from=lotus-builder /lib/*/librt.so.1 /lib/
COPY --from=lotus-builder /lib/*/libgcc_s.so.1 /lib/
COPY --from=lotus-builder /lib/*/libutil.so.1 /lib/
COPY --from=lotus-builder /usr/lib/*/libltdl.so.7 /lib/
COPY --from=lotus-builder /usr/lib/*/libnuma.so.1 /lib/
COPY --from=lotus-builder /usr/lib/*/libhwloc.so.* /lib/
COPY --from=lotus-builder /usr/lib/*/libOpenCL.so.1 /lib/

RUN useradd -r -u 532 -U fc \
&& mkdir -p /etc/OpenCL/vendors \
&& echo "libnvidia-opencl.so.1" > /etc/OpenCL/vendors/nvidia.icd

#####################################
FROM lotus-base AS lotus
MAINTAINER Lotus Development Team

COPY --from=lotus-builder /opt/filecoin/lotus /usr/local/bin/
COPY --from=lotus-builder /opt/filecoin/lotus-shed /usr/local/bin/
COPY scripts/docker-lotus-entrypoint.sh /

ARG DOCKER_LOTUS_IMPORT_SNAPSHOT https://snapshots.mainnet.filops.net/minimal/latest
ENV DOCKER_LOTUS_IMPORT_SNAPSHOT ${DOCKER_LOTUS_IMPORT_SNAPSHOT}
ENV FILECOIN_PARAMETER_CACHE /var/tmp/filecoin-proof-parameters
ENV LOTUS_PATH /var/lib/lotus
ENV DOCKER_LOTUS_IMPORT_WALLET ""

RUN mkdir /var/lib/lotus /var/tmp/filecoin-proof-parameters
RUN chown fc: /var/lib/lotus /var/tmp/filecoin-proof-parameters

VOLUME /var/lib/lotus
VOLUME /var/tmp/filecoin-proof-parameters

USER fc

EXPOSE 1234

ENTRYPOINT ["/docker-lotus-entrypoint.sh"]

CMD ["-help"]

#####################################
FROM lotus-base AS lotus-all-in-one

ENV FILECOIN_PARAMETER_CACHE /var/tmp/filecoin-proof-parameters
ENV LOTUS_MINER_PATH /var/lib/lotus-miner
ENV LOTUS_PATH /var/lib/lotus
ENV LOTUS_WORKER_PATH /var/lib/lotus-worker
ENV WALLET_PATH /var/lib/lotus-wallet

COPY --from=lotus-builder /opt/filecoin/lotus /usr/local/bin/
COPY --from=lotus-builder /opt/filecoin/lotus-seed /usr/local/bin/
COPY --from=lotus-builder /opt/filecoin/lotus-shed /usr/local/bin/
COPY --from=lotus-builder /opt/filecoin/lotus-wallet /usr/local/bin/
COPY --from=lotus-builder /opt/filecoin/lotus-gateway /usr/local/bin/
COPY --from=lotus-builder /opt/filecoin/lotus-miner /usr/local/bin/
COPY --from=lotus-builder /opt/filecoin/lotus-worker /usr/local/bin/
COPY --from=lotus-builder /opt/filecoin/lotus-stats /usr/local/bin/
COPY --from=lotus-builder /opt/filecoin/lotus-fountain /usr/local/bin/

RUN mkdir /var/tmp/filecoin-proof-parameters
RUN mkdir /var/lib/lotus
RUN mkdir /var/lib/lotus-miner
RUN mkdir /var/lib/lotus-worker
RUN mkdir /var/lib/lotus-wallet
RUN chown fc: /var/tmp/filecoin-proof-parameters
RUN chown fc: /var/lib/lotus
RUN chown fc: /var/lib/lotus-miner
RUN chown fc: /var/lib/lotus-worker
RUN chown fc: /var/lib/lotus-wallet


VOLUME /var/tmp/filecoin-proof-parameters
VOLUME /var/lib/lotus
VOLUME /var/lib/lotus-miner
VOLUME /var/lib/lotus-worker
VOLUME /var/lib/lotus-wallet

EXPOSE 1234
EXPOSE 2345
EXPOSE 3456
EXPOSE 1777
# ENTRYPOINT ["/script/init.sh"]
26 changes: 26 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -379,3 +379,29 @@ print-%:

circleci:
go generate -x ./.circleci

TAG:=test
docker: $(BUILD_DEPS)
# ifdef DOCKERFILE
# cp $(DOCKERFILE) ./dockerfile
# else
# curl -o dockerfile https://raw.githubusercontent.com/filecoin-project/venus-docs/master/script/docker/dockerfile
# endif
docker build --build-arg HTTPS_PROXY=$(BUILD_DOCKER_PROXY) --build-arg BUILD_TARGET=lotus -t lotus .
docker tag lotus filvenus/lotus:$(TAG)
ifdef PRIVATE_REGISTRY
docker tag lotus $(PRIVATE_REGISTRY)/filvenus/lotus:$(TAG)
endif
.PHONY: docker

docker-push: docker
ifdef PRIVATE_REGISTRY
docker push $(PRIVATE_REGISTRY)/filvenus/lotus:$(TAG)
docker tag $(PRIVATE_REGISTRY)/filvenus/lotus:$(TAG) $(PRIVATE_REGISTRY)/filvenus/lotus:latest
docker push $(PRIVATE_REGISTRY)/filvenus/lotus:latest
else
docker push filvenus/lotus:$(TAG)
docker tag filvenus/lotus:$(TAG) filvenus/lotus:latest
docker push filvenus/lotus:latest
endif
.PHONY: docker-push
28 changes: 24 additions & 4 deletions build/params_force.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package build

import (
"fmt"
"os"
"strconv"

Expand All @@ -21,8 +22,9 @@ const GenesisFile = ""

var NetworkBundle = "testing"
var BundleOverrides map[actorstypes.Version]string
var ActorDebugging = true

const GenesisNetworkVersion = network.Version18
const GenesisNetworkVersion = network.Version20

var UpgradeBreezeHeight = abi.ChainEpoch(-1)

Expand Down Expand Up @@ -60,9 +62,17 @@ var UpgradeSharkHeight = abi.ChainEpoch(-20)

var UpgradeHyggeHeight = abi.ChainEpoch(-21)

var UpgradeLightningHeight = abi.ChainEpoch(30)
var UpgradeLightningHeight = abi.ChainEpoch(-22)

var UpgradeThunderHeight = abi.ChainEpoch(1000)
var UpgradeThunderHeight = abi.ChainEpoch(-23)

var UpgradeWatermelonHeight = abi.ChainEpoch(200)

// This fix upgrade only ran on calibrationnet
var UpgradeWatermelonFixHeight = abi.ChainEpoch(-100)

// This fix upgrade only ran on calibrationnet
var UpgradeWatermelonFix2Height = abi.ChainEpoch(-101)

var DrandSchedule = map[abi.ChainEpoch]DrandEnum{
0: DrandMainnet,
Expand Down Expand Up @@ -123,9 +133,15 @@ func init() {

BuildType |= BuildForce

newBlockDelaySecs := uint64(getUpgradeHeight("LOTUS_BLOCK_DELAY_SECS", 30))
if newBlockDelaySecs < BlockDelaySecs {
BlockDelaySecs = newBlockDelaySecs
}

fmt.Println("BlockDelaySecs:", BlockDelaySecs)
}

const BlockDelaySecs = uint64(30)
var BlockDelaySecs = uint64(30)

const PropagationDelaySecs = uint64(1)

Expand All @@ -140,4 +156,8 @@ const InteractivePoRepConfidence = 6

const BootstrapPeerThreshold = 1

// ChainId defines the chain ID used in the Ethereum JSON-RPC endpoint.
// As per https://github.com/ethereum-lists/chains
const Eip155ChainId = 31415926

var WhitelistedBlock = cid.Undef
5 changes: 4 additions & 1 deletion chain/stmgr/forks.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,14 +174,17 @@ func (us UpgradeSchedule) GetNtwkVersion(e abi.ChainEpoch) (network.Version, err
return build.GenesisNetworkVersion, nil
}

// noMigrationResultCache will not use cached migration results
var noMigrationResultCache = os.Getenv("LOTUS_NO_MIGRATION_RESULT_CACHE") == "1"

func (sm *StateManager) HandleStateForks(ctx context.Context, root cid.Cid, height abi.ChainEpoch, cb ExecMonitor, ts *types.TipSet) (cid.Cid, error) {
retCid := root
u := sm.stateMigrations[height]
if u != nil && u.upgrade != nil {
if height != build.UpgradeWatermelonFixHeight {
migCid, ok, err := u.migrationResultCache.Get(ctx, root)
if err == nil {
if ok {
if ok && !noMigrationResultCache {
log.Infow("CACHED migration", "height", height, "from", root, "to", migCid)
return migCid, nil
}
Expand Down
33 changes: 28 additions & 5 deletions cli/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ var StateCmd = &cli.Command{
StateMinerInfo,
StateMarketCmd,
StateExecTraceCmd,
StateNtwkVersionCmd,
StateNtwkInfoCmd,
StateMinerProvingDeadlineCmd,
StateSysActorCIDsCmd,
},
Expand Down Expand Up @@ -1836,9 +1836,9 @@ var stateMarketBalanceCmd = &cli.Command{
},
}

var StateNtwkVersionCmd = &cli.Command{
Name: "network-version",
Usage: "Returns the network version",
var StateNtwkInfoCmd = &cli.Command{
Name: "network-info",
Usage: "Returns the network info",
Action: func(cctx *cli.Context) error {
if cctx.Args().Present() {
return ShowHelp(cctx, fmt.Errorf("doesn't expect any arguments"))
Expand All @@ -1862,7 +1862,30 @@ var StateNtwkVersionCmd = &cli.Command{
return err
}

fmt.Printf("Network Version: %d\n", nv)
params, err := api.StateGetNetworkParams(ctx)
if err != nil {
return err
}

partUpgradeHeight := func() []string {
var out []string
rv := reflect.ValueOf(params.ForkUpgradeParams)
rt := rv.Type()
numField := rt.NumField()
for i := numField - 3; i < numField; i++ {
out = append(out, fmt.Sprintf("%s: %v", rt.Field(i).Name, rv.Field(i).Interface()))
}
return out
}

fmt.Println("Network Name:", params.NetworkName)
fmt.Println("Network Version:", nv)
for _, one := range partUpgradeHeight() {
fmt.Println(one)
}
fmt.Println("BlockDelaySecs:", params.BlockDelaySecs)
fmt.Println("PreCommitChallengeDelay:", params.PreCommitChallengeDelay)
// fmt.Println("Chain ID:", params.Eip155ChainID)

return nil
},
Expand Down
16 changes: 12 additions & 4 deletions cmd/lotus-seed/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,24 @@ var genesisNewCmd = &cli.Command{
if !cctx.Args().Present() {
return xerrors.New("seed genesis new [genesis.json]")
}
networkName := cctx.String("network-name")
if len(networkName) == 0 {
// If it is a force network, use forcenet as the network name.
if strings.Contains(build.UserVersion(), "force") {
networkName = "forcenet"
} else {
networkName = "localnet-" + uuid.New().String()
}
}
out := genesis.Template{
NetworkVersion: build.GenesisNetworkVersion,
Accounts: []genesis.Actor{},
Miners: []genesis.Miner{},
VerifregRootKey: gen.DefaultVerifregRootkeyActor,
RemainderAccount: gen.DefaultRemainderAccountActor,
NetworkName: cctx.String("network-name"),
}
if out.NetworkName == "" {
out.NetworkName = "localnet-" + uuid.New().String()
NetworkName: networkName,
// 让第一个块的时间是 00 秒或者 30 秒
Timestamp: uint64(build.Clock.Now().Unix()) / 30 * 30,
}

genb, err := json.MarshalIndent(&out, "", " ")
Expand Down
Loading

0 comments on commit a8312f7

Please sign in to comment.