diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 33a54f14..3425e7b1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -55,7 +55,7 @@ jobs: make chain make contracts # epoch is 200, 400, 500, 1000 - # must wait for 400 block (1.5sec * 400) + # Since we want the previous epoch to be before HF we wait for 800 block (0.75sec * 800) sleep 600 make relayer make test diff --git a/README.md b/README.md index 72a07128..e87285d0 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,8 @@ ## Supported Versions - [yui-relayer v0.5.11](https://github.com/hyperledger-labs/yui-relayer/releases/tag/v0.5.11) -- [ethereum-ibc-relay-chain v0.3.16](https://github.com/datachainlab/ethereum-ibc-relay-chain/releases/tag/v0.3.6) +- [ethereum-ibc-relay-chain v0.3.17](https://github.com/datachainlab/ethereum-ibc-relay-chain/releases/tag/v0.3.7) +- [parlia-elc v0.3.10](https://github.com/datachainlab/parlia-elc/releases/tag/v0.3.10) ## Setup Relayer diff --git a/e2e/chains/bsc/Dockerfile.bootstrap b/e2e/chains/bsc/Dockerfile.bootstrap index bb174fa8..1c0e31d1 100644 --- a/e2e/chains/bsc/Dockerfile.bootstrap +++ b/e2e/chains/bsc/Dockerfile.bootstrap @@ -4,7 +4,7 @@ RUN apk add --d --no-cache npm nodejs bash alpine-sdk expect jq curl bash python RUN curl -sSL https://install.python-poetry.org | python3 - RUN git clone https://github.com/bnb-chain/bsc-genesis-contract -b develop /root/genesis \ - && cd /root/genesis && git checkout 44ebc6c17a00bd24db3240141a78091528dcebbb && npm ci + && cd /root/genesis && git checkout bf3ac733f8aaf93ed88ca0ad2dcddd051166e4e1 && npm ci RUN cd /root/genesis && /root/.local/bin/poetry install RUN cd /root/genesis && forge install --no-git --no-commit foundry-rs/forge-std@v1.7.3 diff --git a/e2e/chains/bsc/docker-compose.bsc.yml b/e2e/chains/bsc/docker-compose.bsc.yml index 376d06dc..b7717c57 100644 --- a/e2e/chains/bsc/docker-compose.bsc.yml +++ b/e2e/chains/bsc/docker-compose.bsc.yml @@ -5,5 +5,5 @@ services: dockerfile: Dockerfile.bsc args: GIT_SOURCE: https://github.com/bnb-chain/bsc - GIT_CHECKOUT_BRANCH: v1.5.10 + GIT_CHECKOUT_BRANCH: v1.5.13 image: bsc-geth:docker-local diff --git a/e2e/chains/bsc/genesis/genesis-template.template b/e2e/chains/bsc/genesis/genesis-template.template index 5a62f795..794f0137 100644 --- a/e2e/chains/bsc/genesis/genesis-template.template +++ b/e2e/chains/bsc/genesis/genesis-template.template @@ -36,6 +36,7 @@ "pascalTime": 0, "pragueTime": 0, "lorentzTime": 0, + "maxwellTime": 0, "blobSchedule": { "cancun": { "target": 3, diff --git a/e2e/chains/bsc/scripts/bootstrap.sh b/e2e/chains/bsc/scripts/bootstrap.sh index c1e6d985..78ad99af 100755 --- a/e2e/chains/bsc/scripts/bootstrap.sh +++ b/e2e/chains/bsc/scripts/bootstrap.sh @@ -56,6 +56,8 @@ function generate_genesis() { echo "start generate process" /root/.local/bin/poetry run python3 scripts/generate.py dev + echo "move generate-dev.json to genesis.json" + mv genesis-dev.json genesis.json } function init_genesis_data() { diff --git a/module/fork_spec.go b/module/fork_spec.go index 1959c14d..e60394a9 100644 --- a/module/fork_spec.go +++ b/module/fork_spec.go @@ -3,8 +3,10 @@ package module import ( "context" "fmt" + "github.com/cockroachdb/errors" "github.com/hyperledger-labs/yui-relayer/log" "os" + "slices" "strconv" ) @@ -16,75 +18,74 @@ const ( Mainnet Network = "mainnet" ) -var localLorentzHF isForkSpec_HeightOrTimestamp = &ForkSpec_Height{Height: 1} +var localLatestHF isForkSpec_HeightOrTimestamp = &ForkSpec_Height{Height: 2} func init() { - localLorentzHFTimestamp := os.Getenv("LOCAL_LORENTZ_HF_TIMESTAMP") - if localLorentzHFTimestamp != "" { - result, err := strconv.Atoi(localLorentzHFTimestamp) + localLatestHFTimestamp := os.Getenv("LOCAL_LATEST_HF_TIMESTAMP") + if localLatestHFTimestamp != "" { + result, err := strconv.Atoi(localLatestHFTimestamp) if err != nil { panic(err) } - localLorentzHF = &ForkSpec_Timestamp{Timestamp: uint64(result)} + localLatestHF = &ForkSpec_Timestamp{Timestamp: uint64(result)} + } +} + +const ( + indexPascalHF = 0 + indexLorentzHF = 1 + indexMaxwellHF = 2 +) + +func getForkSpecParams() []*ForkSpec { + return []*ForkSpec{ + // Pascal HF + { + AdditionalHeaderItemCount: 1, + EpochLength: 200, + MaxTurnLength: 9, + GasLimitBoundDivider: 256, + EnableHeaderMsec: false, + }, + // Lorentz HF + { + AdditionalHeaderItemCount: 1, + EpochLength: 500, + MaxTurnLength: 64, + GasLimitBoundDivider: 1024, + EnableHeaderMsec: true, + }, + // Maxwell HF + { + AdditionalHeaderItemCount: 1, + EpochLength: 1000, + MaxTurnLength: 64, + GasLimitBoundDivider: 1024, + EnableHeaderMsec: true, + }, } } func GetForkParameters(network Network) []*ForkSpec { + hardForks := getForkSpecParams() switch network { case Localnet: - return []*ForkSpec{ - // Pascal HF - { - // Must Set Milli timestamp - HeightOrTimestamp: &ForkSpec_Height{Height: 0}, - AdditionalHeaderItemCount: 1, - EpochLength: 200, - MaxTurnLength: 9, - }, - // Lorentz HF - { - // Must Set Milli timestamp - HeightOrTimestamp: localLorentzHF, - AdditionalHeaderItemCount: 1, - EpochLength: 500, - MaxTurnLength: 64, - }, - } + hardForks[indexPascalHF].HeightOrTimestamp = &ForkSpec_Height{Height: 0} + hardForks[indexLorentzHF].HeightOrTimestamp = &ForkSpec_Height{Height: 1} + hardForks[indexMaxwellHF].HeightOrTimestamp = localLatestHF + return hardForks case Testnet: - return []*ForkSpec{ - { - // https://forum.bnbchain.org/t/bnb-chain-upgrades-testnet/934 - HeightOrTimestamp: &ForkSpec_Height{Height: 48576786}, - AdditionalHeaderItemCount: 1, - EpochLength: 200, - MaxTurnLength: 9, - }, - { - HeightOrTimestamp: &ForkSpec_Height{Height: 49791365}, - AdditionalHeaderItemCount: 1, - EpochLength: 500, - MaxTurnLength: 64, - }, - } + hardForks[indexPascalHF].HeightOrTimestamp = &ForkSpec_Height{Height: 48576786} + hardForks[indexLorentzHF].HeightOrTimestamp = &ForkSpec_Height{Height: 49791365} + hardForks[indexMaxwellHF].HeightOrTimestamp = &ForkSpec_Height{Height: 52552978} + return hardForks case Mainnet: - return []*ForkSpec{ - { - // https://bscscan.com/block/47618307 - // https://github.com/bnb-chain/bsc/releases/tag/v1.5.7 - HeightOrTimestamp: &ForkSpec_Height{Height: 47618307}, - AdditionalHeaderItemCount: 1, - EpochLength: 200, - MaxTurnLength: 9, - }, - // https://bscscan.com/block/48773576 - // https://github.com/bnb-chain/bsc/releases/tag/v1.5.10 - { - HeightOrTimestamp: &ForkSpec_Height{Height: 48773576}, - AdditionalHeaderItemCount: 1, - EpochLength: 500, - MaxTurnLength: 64, - }, - } + hardForks[indexPascalHF].HeightOrTimestamp = &ForkSpec_Height{Height: 47618307} + // https://bscscan.com/block/48773576 + // https://github.com/bnb-chain/bsc/releases/tag/v1.5.10 + hardForks[indexLorentzHF].HeightOrTimestamp = &ForkSpec_Height{Height: 48773576} + //TODO Maxwell + return hardForks } return nil } @@ -103,33 +104,45 @@ type BoundaryHeight struct { CurrentForkSpec ForkSpec } -func (b BoundaryHeight) GetBoundaryEpochs(prevForkSpec ForkSpec) (*BoundaryEpochs, error) { +func (b BoundaryHeight) GetBoundaryEpochs(prevForkSpecs []*ForkSpec) (*BoundaryEpochs, error) { + if len(prevForkSpecs) == 0 { + return nil, errors.New("EmptyPreviousForkSpecs") + } + prevForkSpec := prevForkSpecs[0] boundaryHeight := b.Height prevLast := boundaryHeight - (boundaryHeight % prevForkSpec.EpochLength) - index := uint64(0) currentFirst := uint64(0) - for { - candidate := boundaryHeight + index - if candidate%b.CurrentForkSpec.EpochLength == 0 { - currentFirst = candidate - break - } - index++ + if boundaryHeight%b.CurrentForkSpec.EpochLength == 0 { + currentFirst = boundaryHeight + } else { + currentFirst = boundaryHeight + (b.CurrentForkSpec.EpochLength - boundaryHeight%b.CurrentForkSpec.EpochLength) } + intermediates := make([]uint64, 0) - // starts 0, 200, 400...epoch_length + if prevLast == 0 { - const defaultEpochLength = 200 - for mid := prevLast + defaultEpochLength; mid < prevForkSpec.EpochLength; mid += defaultEpochLength { - intermediates = append(intermediates, mid) + epochLengthList := uniqMap(prevForkSpecs, func(item *ForkSpec, index int) uint64 { + return item.EpochLength + }) + slices.Reverse(epochLengthList) + for i := 0; i < len(epochLengthList)-1; i++ { + start, end := epochLengthList[i], epochLengthList[i+1] + value := start + for value < end { + intermediates = append(intermediates, value) + value += start + } } } - for mid := prevLast + prevForkSpec.EpochLength; mid < currentFirst; mid += prevForkSpec.EpochLength { + + mid := prevLast + prevForkSpec.EpochLength + for mid < currentFirst { intermediates = append(intermediates, mid) + mid += prevForkSpec.EpochLength } return &BoundaryEpochs{ - PreviousForkSpec: prevForkSpec, + PreviousForkSpec: *prevForkSpec, CurrentForkSpec: b.CurrentForkSpec, BoundaryHeight: boundaryHeight, PrevLast: prevLast, @@ -180,27 +193,27 @@ func (be BoundaryEpochs) PreviousEpochBlockNumber(currentEpochBlockNumber uint64 return currentEpochBlockNumber - be.CurrentForkSpec.EpochLength } -func FindTargetForkSpec(forkSpecs []*ForkSpec, height uint64, timestamp uint64) (*ForkSpec, *ForkSpec, error) { +func FindTargetForkSpec(forkSpecs []*ForkSpec, height uint64, timestamp uint64) (*ForkSpec, []*ForkSpec, error) { reversed := make([]*ForkSpec, len(forkSpecs)) for i, spec := range forkSpecs { reversed[len(forkSpecs)-i-1] = spec } - getPrev := func(current *ForkSpec, i int) *ForkSpec { + getPreviousForkSpecs := func(current *ForkSpec, i int) []*ForkSpec { if i == len(reversed)-1 { - return current + return []*ForkSpec{current} } - return reversed[i+1] + return reversed[i+1:] } for i, spec := range reversed { if x, ok := spec.GetHeightOrTimestamp().(*ForkSpec_Height); ok { if x.Height <= height { - return spec, getPrev(spec, i), nil + return spec, getPreviousForkSpecs(spec, i), nil } } else { if spec.GetTimestamp() <= timestamp { - return spec, getPrev(spec, i), nil + return spec, getPreviousForkSpecs(spec, i), nil } } } diff --git a/module/fork_spec_test.go b/module/fork_spec_test.go index 6fee38ed..2eff39d4 100644 --- a/module/fork_spec_test.go +++ b/module/fork_spec_test.go @@ -35,7 +35,7 @@ func (ts *ForkSpecTestSuite) Test_FindTargetForkSpec_ValidHeight() { ts.NoError(err) ts.Equal(forkSpecs[0], current) - ts.Equal(forkSpecs[0], previous) + ts.Equal(forkSpecs[0], previous[0]) } func (ts *ForkSpecTestSuite) Test_FindTargetForkSpec_ValidHeight2() { @@ -50,7 +50,7 @@ func (ts *ForkSpecTestSuite) Test_FindTargetForkSpec_ValidHeight2() { ts.NoError(err) ts.Equal(forkSpecs[1], current) - ts.Equal(forkSpecs[0], previous) + ts.Equal(forkSpecs[0], previous[0]) } func (ts *ForkSpecTestSuite) Test_FindTargetForkSpec_ValidTimestamp() { @@ -65,7 +65,7 @@ func (ts *ForkSpecTestSuite) Test_FindTargetForkSpec_ValidTimestamp() { ts.NoError(err) ts.Equal(forkSpecs[0], current) - ts.Equal(forkSpecs[0], previous) + ts.Equal(forkSpecs[0], previous[0]) } func (ts *ForkSpecTestSuite) Test_FindTargetForkSpec_ValidTimestamp2() { @@ -80,7 +80,7 @@ func (ts *ForkSpecTestSuite) Test_FindTargetForkSpec_ValidTimestamp2() { ts.NoError(err) ts.Equal(forkSpecs[1], current) - ts.Equal(forkSpecs[0], previous) + ts.Equal(forkSpecs[0], previous[0]) } func (ts *ForkSpecTestSuite) Test_FindTargetForkSpec_NoMatch() { @@ -110,7 +110,7 @@ func (ts *ForkSpecTestSuite) Test_FindTargetForkSpec_Both() { ts.NoError(err) ts.Equal(forkSpecs[1], current) - ts.Equal(forkSpecs[0], previous) + ts.Equal(forkSpecs[0], previous[0]) } func (ts *ForkSpecTestSuite) Test_FindTargetForkSpec_EmptyForkSpecs() { @@ -203,47 +203,136 @@ func (ts *ForkSpecTestSuite) Test_GetBoundaryHeight_HeaderFnError() { } func (ts *ForkSpecTestSuite) Test_Success_GetBoundaryEpochs() { - forkSpecs := []*ForkSpec{ - {HeightOrTimestamp: &ForkSpec_Height{Height: 0}, EpochLength: 200}, - {EpochLength: 500}, - } - epochs, err := BoundaryHeight{Height: 1501, CurrentForkSpec: *forkSpecs[1]}.GetBoundaryEpochs(*forkSpecs[0]) + pascalHF := &ForkSpec{HeightOrTimestamp: &ForkSpec_Height{Height: 0}, EpochLength: 200} + lorentzHF := &ForkSpec{HeightOrTimestamp: &ForkSpec_Height{Height: 1}, EpochLength: 500} + maxwellHF := &ForkSpec{HeightOrTimestamp: &ForkSpec_Height{Height: 1}, EpochLength: 1000} + postMaxwellHF1 := &ForkSpec{HeightOrTimestamp: &ForkSpec_Height{Height: 1}, EpochLength: 1000} + postMaxwellHF2 := &ForkSpec{HeightOrTimestamp: &ForkSpec_Height{Height: 1}, EpochLength: 2000} + + // Check lorentzHF + epochs, err := BoundaryHeight{Height: 1501, CurrentForkSpec: *lorentzHF}.GetBoundaryEpochs([]*ForkSpec{pascalHF}) ts.Require().NoError(err) ts.Require().Equal(epochs.PrevLast, uint64(1400)) ts.Require().Equal(epochs.Intermediates, []uint64{1600, 1800}) ts.Require().Equal(epochs.CurrentFirst, uint64(2000)) - epochs, err = BoundaryHeight{Height: 1600, CurrentForkSpec: *forkSpecs[1]}.GetBoundaryEpochs(*forkSpecs[0]) + epochs, err = BoundaryHeight{Height: 1600, CurrentForkSpec: *lorentzHF}.GetBoundaryEpochs([]*ForkSpec{pascalHF}) ts.Require().NoError(err) ts.Require().Equal(epochs.PrevLast, uint64(1600)) ts.Require().Equal(epochs.Intermediates, []uint64{1800}) ts.Require().Equal(epochs.CurrentFirst, uint64(2000)) - epochs, err = BoundaryHeight{Height: 1601, CurrentForkSpec: *forkSpecs[1]}.GetBoundaryEpochs(*forkSpecs[0]) + epochs, err = BoundaryHeight{Height: 1601, CurrentForkSpec: *lorentzHF}.GetBoundaryEpochs([]*ForkSpec{pascalHF}) ts.Require().NoError(err) ts.Require().Equal(epochs.PrevLast, uint64(1600)) ts.Require().Equal(epochs.Intermediates, []uint64{1800}) ts.Require().Equal(epochs.CurrentFirst, uint64(2000)) - epochs, err = BoundaryHeight{Height: 1800, CurrentForkSpec: *forkSpecs[1]}.GetBoundaryEpochs(*forkSpecs[0]) + epochs, err = BoundaryHeight{Height: 1800, CurrentForkSpec: *lorentzHF}.GetBoundaryEpochs([]*ForkSpec{pascalHF}) ts.Require().NoError(err) ts.Require().Equal(epochs.PrevLast, uint64(1800)) ts.Require().Equal(epochs.Intermediates, []uint64{}) ts.Require().Equal(epochs.CurrentFirst, uint64(2000)) - epochs, err = BoundaryHeight{Height: 2000, CurrentForkSpec: *forkSpecs[1]}.GetBoundaryEpochs(*forkSpecs[0]) + epochs, err = BoundaryHeight{Height: 2000, CurrentForkSpec: *lorentzHF}.GetBoundaryEpochs([]*ForkSpec{pascalHF}) + ts.Require().NoError(err) + ts.Require().Equal(epochs.PrevLast, uint64(2000)) + ts.Require().Equal(epochs.Intermediates, []uint64{}) + ts.Require().Equal(epochs.CurrentFirst, uint64(2000)) + + // Check maxwell + epochs, err = BoundaryHeight{Height: 1501, CurrentForkSpec: *maxwellHF}.GetBoundaryEpochs([]*ForkSpec{lorentzHF, pascalHF}) + ts.Require().NoError(err) + ts.Require().Equal(epochs.PrevLast, uint64(1500)) + ts.Require().Equal(epochs.Intermediates, []uint64{}) + ts.Require().Equal(epochs.CurrentFirst, uint64(2000)) + + epochs, err = BoundaryHeight{Height: 2000, CurrentForkSpec: *maxwellHF}.GetBoundaryEpochs([]*ForkSpec{lorentzHF, pascalHF}) ts.Require().NoError(err) ts.Require().Equal(epochs.PrevLast, uint64(2000)) ts.Require().Equal(epochs.Intermediates, []uint64{}) ts.Require().Equal(epochs.CurrentFirst, uint64(2000)) + + epochs, err = BoundaryHeight{Height: 2001, CurrentForkSpec: *maxwellHF}.GetBoundaryEpochs([]*ForkSpec{lorentzHF, pascalHF}) + ts.Require().NoError(err) + ts.Require().Equal(epochs.PrevLast, uint64(2000)) + ts.Require().Equal(epochs.Intermediates, []uint64{2500}) + ts.Require().Equal(epochs.CurrentFirst, uint64(3000)) + + epochs, err = BoundaryHeight{Height: 3000, CurrentForkSpec: *maxwellHF}.GetBoundaryEpochs([]*ForkSpec{lorentzHF, pascalHF}) + ts.Require().NoError(err) + ts.Require().Equal(epochs.PrevLast, uint64(3000)) + ts.Require().Equal(epochs.Intermediates, []uint64{}) + ts.Require().Equal(epochs.CurrentFirst, uint64(3000)) + + // Check post maxwell 1 + epochs, err = BoundaryHeight{Height: 1501, CurrentForkSpec: *postMaxwellHF1}.GetBoundaryEpochs([]*ForkSpec{maxwellHF, lorentzHF, pascalHF}) + ts.Require().NoError(err) + ts.Require().Equal(epochs.PrevLast, uint64(1000)) + ts.Require().Equal(epochs.Intermediates, []uint64{}) + ts.Require().Equal(epochs.CurrentFirst, uint64(2000)) + + epochs, err = BoundaryHeight{Height: 2000, CurrentForkSpec: *postMaxwellHF1}.GetBoundaryEpochs([]*ForkSpec{maxwellHF, lorentzHF, pascalHF}) + ts.Require().NoError(err) + ts.Require().Equal(epochs.PrevLast, uint64(2000)) + ts.Require().Equal(epochs.Intermediates, []uint64{}) + ts.Require().Equal(epochs.CurrentFirst, uint64(2000)) + + epochs, err = BoundaryHeight{Height: 2001, CurrentForkSpec: *postMaxwellHF1}.GetBoundaryEpochs([]*ForkSpec{maxwellHF, lorentzHF, pascalHF}) + ts.Require().NoError(err) + ts.Require().Equal(epochs.PrevLast, uint64(2000)) + ts.Require().Equal(epochs.Intermediates, []uint64{}) + ts.Require().Equal(epochs.CurrentFirst, uint64(3000)) + + epochs, err = BoundaryHeight{Height: 3000, CurrentForkSpec: *postMaxwellHF1}.GetBoundaryEpochs([]*ForkSpec{maxwellHF, lorentzHF, pascalHF}) + ts.Require().NoError(err) + ts.Require().Equal(epochs.PrevLast, uint64(3000)) + ts.Require().Equal(epochs.Intermediates, []uint64{}) + ts.Require().Equal(epochs.CurrentFirst, uint64(3000)) + + // Check post maxwell 2 + epochs, err = BoundaryHeight{Height: 1501, CurrentForkSpec: *postMaxwellHF2}.GetBoundaryEpochs([]*ForkSpec{postMaxwellHF1, maxwellHF, lorentzHF, pascalHF}) + ts.Require().NoError(err) + ts.Require().Equal(epochs.PrevLast, uint64(1000)) + ts.Require().Equal(epochs.Intermediates, []uint64{}) + ts.Require().Equal(epochs.CurrentFirst, uint64(2000)) + + epochs, err = BoundaryHeight{Height: 2000, CurrentForkSpec: *postMaxwellHF2}.GetBoundaryEpochs([]*ForkSpec{postMaxwellHF1, maxwellHF, lorentzHF, pascalHF}) + ts.Require().NoError(err) + ts.Require().Equal(epochs.PrevLast, uint64(2000)) + ts.Require().Equal(epochs.Intermediates, []uint64{}) + ts.Require().Equal(epochs.CurrentFirst, uint64(2000)) + + epochs, err = BoundaryHeight{Height: 2001, CurrentForkSpec: *postMaxwellHF2}.GetBoundaryEpochs([]*ForkSpec{postMaxwellHF1, maxwellHF, lorentzHF, pascalHF}) + ts.Require().NoError(err) + ts.Require().Equal(epochs.PrevLast, uint64(2000)) + ts.Require().Equal(epochs.Intermediates, []uint64{3000}) + ts.Require().Equal(epochs.CurrentFirst, uint64(4000)) + + epochs, err = BoundaryHeight{Height: 3000, CurrentForkSpec: *postMaxwellHF2}.GetBoundaryEpochs([]*ForkSpec{postMaxwellHF1, maxwellHF, lorentzHF, pascalHF}) + ts.Require().NoError(err) + ts.Require().Equal(epochs.PrevLast, uint64(3000)) + ts.Require().Equal(epochs.Intermediates, []uint64{}) + ts.Require().Equal(epochs.CurrentFirst, uint64(4000)) + + epochs, err = BoundaryHeight{Height: 4000, CurrentForkSpec: *postMaxwellHF2}.GetBoundaryEpochs([]*ForkSpec{postMaxwellHF1, maxwellHF, lorentzHF, pascalHF}) + ts.Require().NoError(err) + ts.Require().Equal(epochs.PrevLast, uint64(4000)) + ts.Require().Equal(epochs.Intermediates, []uint64{}) + ts.Require().Equal(epochs.CurrentFirst, uint64(4000)) + + epochs, err = BoundaryHeight{Height: 4001, CurrentForkSpec: *postMaxwellHF2}.GetBoundaryEpochs([]*ForkSpec{postMaxwellHF1, maxwellHF, lorentzHF, pascalHF}) + ts.Require().NoError(err) + ts.Require().Equal(epochs.PrevLast, uint64(4000)) + ts.Require().Equal(epochs.Intermediates, []uint64{5000}) + ts.Require().Equal(epochs.CurrentFirst, uint64(6000)) } func (ts *ForkSpecTestSuite) Test_Success_GetBoundaryEpochs_After_Lorentz() { - forkSpecs := []*ForkSpec{ - {HeightOrTimestamp: &ForkSpec_Height{Height: 0}, EpochLength: 200}, - {EpochLength: 500}, - } - epochs, err := BoundaryHeight{Height: 1, CurrentForkSpec: *forkSpecs[1]}.GetBoundaryEpochs(*forkSpecs[0]) + pascalHF := &ForkSpec{HeightOrTimestamp: &ForkSpec_Height{Height: 0}, EpochLength: 200} + lorentzHF := &ForkSpec{HeightOrTimestamp: &ForkSpec_Height{Height: 1}, EpochLength: 500} + + epochs, err := BoundaryHeight{Height: 1, CurrentForkSpec: *lorentzHF}.GetBoundaryEpochs([]*ForkSpec{pascalHF}) ts.Require().NoError(err) ts.Require().Equal(epochs.PrevLast, uint64(0)) ts.Require().Equal(epochs.Intermediates, []uint64{200, 400}) @@ -271,11 +360,50 @@ func (ts *ForkSpecTestSuite) Test_Success_GetBoundaryEpochs_After_Lorentz() { } func (ts *ForkSpecTestSuite) Test_Success_GetBoundaryEpochs_After_Maxwell() { - forkSpecs := []*ForkSpec{ - {HeightOrTimestamp: &ForkSpec_Height{Height: 0}, EpochLength: 500}, - {EpochLength: 1000}, - } - epochs, err := BoundaryHeight{Height: 1, CurrentForkSpec: *forkSpecs[1]}.GetBoundaryEpochs(*forkSpecs[0]) + pascalHF := &ForkSpec{HeightOrTimestamp: &ForkSpec_Height{Height: 0}, EpochLength: 200} + lorentzHF := &ForkSpec{HeightOrTimestamp: &ForkSpec_Height{Height: 1}, EpochLength: 500} + maxwellHF := &ForkSpec{HeightOrTimestamp: &ForkSpec_Height{Height: 1}, EpochLength: 1000} + + epochs, err := BoundaryHeight{Height: 1, CurrentForkSpec: *maxwellHF}.GetBoundaryEpochs([]*ForkSpec{lorentzHF, pascalHF}) + ts.Require().NoError(err) + ts.Require().Equal(epochs.PrevLast, uint64(0)) + ts.Require().Equal(epochs.Intermediates, []uint64{200, 400, 500}) + ts.Require().Equal(epochs.CurrentFirst, uint64(1000)) + ts.Require().Equal(epochs.CurrentEpochBlockNumber(199), uint64(0)) + ts.Require().Equal(epochs.CurrentEpochBlockNumber(200), uint64(200)) + ts.Require().Equal(epochs.CurrentEpochBlockNumber(399), uint64(200)) + ts.Require().Equal(epochs.CurrentEpochBlockNumber(400), uint64(400)) + ts.Require().Equal(epochs.CurrentEpochBlockNumber(499), uint64(400)) + ts.Require().Equal(epochs.CurrentEpochBlockNumber(500), uint64(500)) + ts.Require().Equal(epochs.CurrentEpochBlockNumber(501), uint64(500)) + ts.Require().Equal(epochs.CurrentEpochBlockNumber(999), uint64(500)) + ts.Require().Equal(epochs.CurrentEpochBlockNumber(1000), uint64(1000)) + ts.Require().Equal(epochs.CurrentEpochBlockNumber(1001), uint64(1000)) + ts.Require().Equal(epochs.CurrentEpochBlockNumber(1499), uint64(1000)) + ts.Require().Equal(epochs.CurrentEpochBlockNumber(1500), uint64(1000)) + ts.Require().Equal(epochs.CurrentEpochBlockNumber(1501), uint64(1000)) + ts.Require().Equal(epochs.CurrentEpochBlockNumber(1999), uint64(1000)) + ts.Require().Equal(epochs.CurrentEpochBlockNumber(2000), uint64(2000)) + ts.Require().Equal(epochs.CurrentEpochBlockNumber(2001), uint64(2000)) + ts.Require().Equal(epochs.CurrentEpochBlockNumber(2999), uint64(2000)) + ts.Require().Equal(epochs.CurrentEpochBlockNumber(3000), uint64(3000)) + + ts.Require().Equal(epochs.PreviousEpochBlockNumber(0), uint64(0)) + ts.Require().Equal(epochs.PreviousEpochBlockNumber(200), uint64(0)) + ts.Require().Equal(epochs.PreviousEpochBlockNumber(400), uint64(200)) + ts.Require().Equal(epochs.PreviousEpochBlockNumber(500), uint64(400)) + ts.Require().Equal(epochs.PreviousEpochBlockNumber(1000), uint64(500)) + ts.Require().Equal(epochs.PreviousEpochBlockNumber(2000), uint64(1000)) + ts.Require().Equal(epochs.PreviousEpochBlockNumber(3000), uint64(2000)) +} + +func (ts *ForkSpecTestSuite) Test_Success_GetBoundaryEpochs_After_Maxwell_1() { + pascalHF := &ForkSpec{HeightOrTimestamp: &ForkSpec_Height{Height: 0}, EpochLength: 200} + lorentzHF := &ForkSpec{HeightOrTimestamp: &ForkSpec_Height{Height: 1}, EpochLength: 500} + maxwellHF := &ForkSpec{HeightOrTimestamp: &ForkSpec_Height{Height: 1}, EpochLength: 1000} + postMaxwellHF1 := &ForkSpec{HeightOrTimestamp: &ForkSpec_Height{Height: 1}, EpochLength: 1000} + + epochs, err := BoundaryHeight{Height: 1, CurrentForkSpec: *postMaxwellHF1}.GetBoundaryEpochs([]*ForkSpec{maxwellHF, lorentzHF, pascalHF}) ts.Require().NoError(err) ts.Require().Equal(epochs.PrevLast, uint64(0)) ts.Require().Equal(epochs.Intermediates, []uint64{200, 400, 500}) @@ -307,3 +435,43 @@ func (ts *ForkSpecTestSuite) Test_Success_GetBoundaryEpochs_After_Maxwell() { ts.Require().Equal(epochs.PreviousEpochBlockNumber(2000), uint64(1000)) ts.Require().Equal(epochs.PreviousEpochBlockNumber(3000), uint64(2000)) } + +func (ts *ForkSpecTestSuite) Test_Success_GetBoundaryEpochs_After_Maxwell_2() { + pascalHF := &ForkSpec{HeightOrTimestamp: &ForkSpec_Height{Height: 0}, EpochLength: 200} + lorentzHF := &ForkSpec{HeightOrTimestamp: &ForkSpec_Height{Height: 1}, EpochLength: 500} + maxwellHF := &ForkSpec{HeightOrTimestamp: &ForkSpec_Height{Height: 1}, EpochLength: 1000} + postMaxwellHF1 := &ForkSpec{HeightOrTimestamp: &ForkSpec_Height{Height: 1}, EpochLength: 1000} + postMaxwellHF2 := &ForkSpec{HeightOrTimestamp: &ForkSpec_Height{Height: 1}, EpochLength: 2000} + + epochs, err := BoundaryHeight{Height: 1, CurrentForkSpec: *postMaxwellHF2}.GetBoundaryEpochs([]*ForkSpec{postMaxwellHF1, maxwellHF, lorentzHF, pascalHF}) + ts.Require().NoError(err) + ts.Require().Equal(epochs.PrevLast, uint64(0)) + ts.Require().Equal(epochs.Intermediates, []uint64{200, 400, 500, 1000}) + ts.Require().Equal(epochs.CurrentFirst, uint64(2000)) + ts.Require().Equal(epochs.CurrentEpochBlockNumber(199), uint64(0)) + ts.Require().Equal(epochs.CurrentEpochBlockNumber(200), uint64(200)) + ts.Require().Equal(epochs.CurrentEpochBlockNumber(399), uint64(200)) + ts.Require().Equal(epochs.CurrentEpochBlockNumber(400), uint64(400)) + ts.Require().Equal(epochs.CurrentEpochBlockNumber(499), uint64(400)) + ts.Require().Equal(epochs.CurrentEpochBlockNumber(500), uint64(500)) + ts.Require().Equal(epochs.CurrentEpochBlockNumber(501), uint64(500)) + ts.Require().Equal(epochs.CurrentEpochBlockNumber(999), uint64(500)) + ts.Require().Equal(epochs.CurrentEpochBlockNumber(1000), uint64(1000)) + ts.Require().Equal(epochs.CurrentEpochBlockNumber(1001), uint64(1000)) + ts.Require().Equal(epochs.CurrentEpochBlockNumber(1499), uint64(1000)) + ts.Require().Equal(epochs.CurrentEpochBlockNumber(1500), uint64(1000)) + ts.Require().Equal(epochs.CurrentEpochBlockNumber(1501), uint64(1000)) + ts.Require().Equal(epochs.CurrentEpochBlockNumber(1999), uint64(1000)) + ts.Require().Equal(epochs.CurrentEpochBlockNumber(2000), uint64(2000)) + ts.Require().Equal(epochs.CurrentEpochBlockNumber(2001), uint64(2000)) + ts.Require().Equal(epochs.CurrentEpochBlockNumber(2999), uint64(2000)) + ts.Require().Equal(epochs.CurrentEpochBlockNumber(3000), uint64(2000)) + + ts.Require().Equal(epochs.PreviousEpochBlockNumber(0), uint64(0)) + ts.Require().Equal(epochs.PreviousEpochBlockNumber(200), uint64(0)) + ts.Require().Equal(epochs.PreviousEpochBlockNumber(400), uint64(200)) + ts.Require().Equal(epochs.PreviousEpochBlockNumber(500), uint64(400)) + ts.Require().Equal(epochs.PreviousEpochBlockNumber(1000), uint64(500)) + ts.Require().Equal(epochs.PreviousEpochBlockNumber(2000), uint64(1000)) + ts.Require().Equal(epochs.PreviousEpochBlockNumber(3000), uint64(1000)) +} diff --git a/module/parlia.pb.go b/module/parlia.pb.go index 6915774d..40645676 100644 --- a/module/parlia.pb.go +++ b/module/parlia.pb.go @@ -36,6 +36,8 @@ type ForkSpec struct { AdditionalHeaderItemCount uint64 `protobuf:"varint,3,opt,name=additional_header_item_count,json=additionalHeaderItemCount,proto3" json:"additional_header_item_count,omitempty"` EpochLength uint64 `protobuf:"varint,4,opt,name=epoch_length,json=epochLength,proto3" json:"epoch_length,omitempty"` MaxTurnLength uint64 `protobuf:"varint,5,opt,name=max_turn_length,json=maxTurnLength,proto3" json:"max_turn_length,omitempty"` + GasLimitBoundDivider uint64 `protobuf:"varint,6,opt,name=gas_limit_bound_divider,json=gasLimitBoundDivider,proto3" json:"gas_limit_bound_divider,omitempty"` + EnableHeaderMsec bool `protobuf:"varint,7,opt,name=enable_header_msec,json=enableHeaderMsec,proto3" json:"enable_header_msec,omitempty"` } func (m *ForkSpec) Reset() { *m = ForkSpec{} } @@ -371,63 +373,66 @@ func init() { } var fileDescriptor_dc631224085c6c85 = []byte{ - // 882 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x54, 0x4d, 0x6f, 0x23, 0x35, - 0x18, 0xce, 0x34, 0x25, 0x4d, 0x9c, 0x64, 0xcb, 0xba, 0xbb, 0xcb, 0xb4, 0x2c, 0x69, 0xc9, 0xf2, - 0x51, 0x90, 0x3a, 0x43, 0x82, 0x84, 0xb8, 0xa0, 0x6a, 0x9b, 0x05, 0xa5, 0x62, 0x57, 0xaa, 0xa6, - 0x2b, 0x0e, 0x08, 0xc9, 0xf2, 0x78, 0x9c, 0x8c, 0xd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x9e, 0xe9, 0x18, 0xfc, 0x00, 0xbc, 0xbe, 0x9a, 0x3e, 0x0e, 0xe7, 0x86, 0xd5, 0x2a, 0x6e, - 0xa0, 0x27, 0x4f, 0x2e, 0x7f, 0x1f, 0x34, 0x2e, 0xaf, 0x06, 0xde, 0x8b, 0xab, 0x81, 0xf7, 0xdb, - 0xd5, 0xc0, 0xfb, 0xfe, 0x7a, 0xd0, 0x78, 0x71, 0x3d, 0x68, 0xfc, 0x7c, 0x3d, 0x68, 0x7c, 0x1d, - 0xce, 0x99, 0x4a, 0xab, 0x38, 0x20, 0x3c, 0x0f, 0x13, 0xac, 0xb0, 0x19, 0x87, 0x19, 0x8e, 0x43, - 0x16, 0x93, 0x23, 0x7b, 0xe5, 0x23, 0x41, 0x33, 0xfc, 0x6d, 0x98, 0xf3, 0xa4, 0xca, 0x68, 0xdc, - 0x32, 0x93, 0xe1, 0xe3, 0x3f, 0x03, 0x00, 0x00, 0xff, 0xff, 0x11, 0x5a, 0xe7, 0x6a, 0xe1, 0x06, - 0x00, 0x00, + // 938 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x54, 0xdd, 0x6e, 0xe3, 0x44, + 0x14, 0x8e, 0xdb, 0x92, 0x26, 0xd3, 0x74, 0xbb, 0x3b, 0xed, 0xee, 0xba, 0x65, 0x49, 0x4b, 0x96, + 0x9f, 0x82, 0xa8, 0xbd, 0x09, 0x02, 0x71, 0x83, 0xaa, 0x6d, 0x0a, 0x4a, 0x45, 0x2b, 0x55, 0xee, + 0x8a, 0x0b, 0x84, 0x34, 0x1a, 0x8f, 0x27, 0xf6, 0xa8, 0xb6, 0x27, 0x9a, 0x19, 0x47, 0x0b, 0x4f, + 0xc1, 0x25, 0xaf, 0xc0, 0x53, 0xec, 0x6d, 0x2f, 0x10, 0xda, 0x4b, 0xae, 0xf8, 0x69, 0x5f, 0x04, + 0xcd, 0x8f, 0x93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 0x26, 0x76, 0x6a, 0x42, 0xf0, 0x1d, 0xb0, + 0x51, 0xe0, 0xe7, 0x48, 0x55, 0xa2, 0xac, 0x51, 0xaf, 0x19, 0xd4, 0x7a, 0x81, 0x9f, 0x3f, 0xab, + 0x44, 0xe9, 0x70, 0x1f, 0x81, 0x87, 0x29, 0x96, 0x28, 0x67, 0x05, 0x53, 0x28, 0xe6, 0x55, 0x99, + 0xa0, 0x84, 0x4d, 0x59, 0x42, 0x85, 0xdf, 0x34, 0xf8, 0xad, 0x14, 0xcb, 0x53, 0x9d, 0x3d, 0xd2, + 0xc9, 0x63, 0x9b, 0x83, 0x1f, 0x00, 0x48, 0x4b, 0x1c, 0xe7, 0xb4, 0xfe, 0xfc, 0x42, 0x52, 0xe2, + 0xaf, 0xee, 0x79, 0xfb, 0xad, 0xe8, 0xae, 0xcd, 0xd8, 0x8f, 0x3e, 0x93, 0x94, 0x1c, 0xdd, 0x07, + 0x9b, 0x56, 0x1a, 0xc4, 0x05, 0x9a, 0xe9, 0xd0, 0x7b, 0xb1, 0x0c, 0xd6, 0x86, 0x46, 0xff, 0x0b, + 0x85, 0x15, 0x85, 0xdb, 0xa0, 0x45, 0x32, 0xcc, 0x4a, 0xc4, 0x12, 0xab, 0x69, 0xb4, 0x6a, 0xee, + 0x27, 0x09, 0x7c, 0x1f, 0xdc, 0x63, 0x31, 0x41, 0x52, 0x71, 0x41, 0x11, 0x4e, 0x12, 0x41, 0xa5, + 0x34, 0xd2, 0x76, 0xa2, 0x0d, 0x16, 0x93, 0x0b, 0x1d, 0x7f, 0x6a, 0xc3, 0xf0, 0x09, 0xd8, 0xd2, + 0x58, 0xc2, 0x8b, 0x82, 0xa9, 0x42, 0x77, 0x06, 0x92, 0x39, 0xb7, 0xb2, 0x76, 0x22, 0xc8, 0x62, + 0x32, 0x9c, 0xa7, 0x2e, 0x72, 0xae, 0xe0, 0x21, 0x58, 0xcf, 0xb1, 0xa2, 0x52, 0x21, 0xe7, 0xa8, + 0x16, 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ff, 0xfc, 0x2f, + 0xfa, 0xa0, 0xf7, 0x35, 0x00, 0xe7, 0x82, 0x4f, 0xa9, 0x15, 0xfa, 0x31, 0x58, 0xc7, 0xc4, 0xac, + 0x69, 0x34, 0x11, 0x9c, 0x8f, 0x9d, 0xd6, 0x1d, 0x17, 0x3c, 0xd7, 0x31, 0xf8, 0x1e, 0xb8, 0x3b, + 0xdf, 0x3e, 0x0e, 0xe7, 0x96, 0xd5, 0x3c, 0x6e, 0xa0, 0x47, 0x67, 0x57, 0xbf, 0x77, 0x1b, 0x57, + 0xd7, 0x5d, 0xef, 0xe5, 0x75, 0xd7, 0xfb, 0xed, 0xba, 0xeb, 0x7d, 0x77, 0xd3, 0x6d, 0xbc, 0xbc, + 0xe9, 0x36, 0x7e, 0xbe, 0xe9, 0x36, 0xbe, 0x0a, 0x53, 0xa6, 0xb2, 0x2a, 0x0e, 0x08, 0x2f, 0xc2, + 0x04, 0x2b, 0x6c, 0xd6, 0x61, 0x8e, 0xe3, 0x90, 0xc5, 0xe4, 0xc0, 0x7e, 0xf2, 0x81, 0xa0, 0x39, + 0xfe, 0x26, 0x2c, 0x78, 0x52, 0xe5, 0x34, 0x6e, 0x9a, 0xcd, 0xf0, 0xe1, 0x1f, 0x01, 0x00, 0x00, + 0xff, 0xff, 0xe0, 0xed, 0x6c, 0xdf, 0x46, 0x07, 0x00, 0x00, } func (m *ForkSpec) Marshal() (dAtA []byte, err error) { @@ -450,6 +455,21 @@ func (m *ForkSpec) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.EnableHeaderMsec { + i-- + if m.EnableHeaderMsec { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x38 + } + if m.GasLimitBoundDivider != 0 { + i = encodeVarintParlia(dAtA, i, uint64(m.GasLimitBoundDivider)) + i-- + dAtA[i] = 0x30 + } if m.MaxTurnLength != 0 { i = encodeVarintParlia(dAtA, i, uint64(m.MaxTurnLength)) i-- @@ -871,6 +891,12 @@ func (m *ForkSpec) Size() (n int) { if m.MaxTurnLength != 0 { n += 1 + sovParlia(uint64(m.MaxTurnLength)) } + if m.GasLimitBoundDivider != 0 { + n += 1 + sovParlia(uint64(m.GasLimitBoundDivider)) + } + if m.EnableHeaderMsec { + n += 2 + } return n } @@ -1173,6 +1199,45 @@ func (m *ForkSpec) Unmarshal(dAtA []byte) error { break } } + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field GasLimitBoundDivider", wireType) + } + m.GasLimitBoundDivider = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParlia + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.GasLimitBoundDivider |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 7: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field EnableHeaderMsec", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParlia + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.EnableHeaderMsec = bool(v != 0) default: iNdEx = preIndex skippy, err := skipParlia(dAtA[iNdEx:]) diff --git a/module/proof.go b/module/proof.go index 9e33e933..7d8213ec 100644 --- a/module/proof.go +++ b/module/proof.go @@ -196,7 +196,7 @@ func withValidators(ctx context.Context, headerFn getHeaderFn, height uint64, et } log.GetLogger().Debug("get boundary height by ", "height", height, "boundaryHeight", boundaryHeight) - boundaryEpochs, err := boundaryHeight.GetBoundaryEpochs(*prevForkSpec) + boundaryEpochs, err := boundaryHeight.GetBoundaryEpochs(prevForkSpec) if err != nil { return nil, err } diff --git a/module/setup.go b/module/setup.go index b7279900..59029079 100644 --- a/module/setup.go +++ b/module/setup.go @@ -83,7 +83,7 @@ func setupHeadersForUpdate( if err != nil { return nil, err } - trustedBoundaryEpochs, err := trustedBoundaryHeight.GetBoundaryEpochs(*trustedPreviousForkSpec) + trustedBoundaryEpochs, err := trustedBoundaryHeight.GetBoundaryEpochs(trustedPreviousForkSpec) if err != nil { return nil, err } diff --git a/module/util.go b/module/util.go index d87b9642..cb76b653 100644 --- a/module/util.go +++ b/module/util.go @@ -15,3 +15,17 @@ func minUint64(x uint64, y uint64) uint64 { } return x } + +func uniqMap[T any, R comparable](collection []T, iteratee func(item T, index int) R) []R { + result := make([]R, 0, len(collection)) + seen := make(map[R]struct{}, len(collection)) + + for i := range collection { + r := iteratee(collection[i], i) + if _, ok := seen[r]; !ok { + result = append(result, r) + seen[r] = struct{}{} + } + } + return result +} diff --git a/proto/ibc/lightclients/parlia/v1/parlia.proto b/proto/ibc/lightclients/parlia/v1/parlia.proto index e67d5e37..5ae4756a 100644 --- a/proto/ibc/lightclients/parlia/v1/parlia.proto +++ b/proto/ibc/lightclients/parlia/v1/parlia.proto @@ -15,6 +15,8 @@ message ForkSpec { uint64 additional_header_item_count = 3; uint64 epoch_length = 4; uint64 max_turn_length = 5; + uint64 gas_limit_bound_divider = 6; + bool enable_header_msec = 7; } message ClientState { diff --git a/tests/prover_network_test.go b/tests/prover_network_test.go index a7a1e6eb..8b50c111 100644 --- a/tests/prover_network_test.go +++ b/tests/prover_network_test.go @@ -97,7 +97,7 @@ func (ts *ProverNetworkTestSuite) TestSuccessCreateInitialLightClientState() { ts.Require().NoError(err) bs, err := module.GetBoundaryHeight(ts.chain.Header, header.Number.Uint64(), *currentForkSpec) ts.Require().NoError(err) - be, err := bs.GetBoundaryEpochs(*prevForkSpec) + be, err := bs.GetBoundaryEpochs(prevForkSpec) ts.Require().NoError(err) currentEpoch := be.CurrentEpochBlockNumber(header.Number.Uint64())