Skip to content

Commit

Permalink
Support Bohr HF (#39)
Browse files Browse the repository at this point in the history
* remove non-neighboring-epoch
* BEP-341 

Signed-off-by: Naohiro Yoshida <[email protected]>
  • Loading branch information
yoshidan authored Aug 16, 2024
1 parent d1408e8 commit 10eaeba
Show file tree
Hide file tree
Showing 36 changed files with 1,242 additions and 2,121 deletions.
13 changes: 12 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,20 @@ on:
push:
branches:
- main
- develop
pull_request:
types:
- opened
- reopened
- synchronize
- ready_for_review

jobs:
unit-test:
name: unit-test
timeout-minutes: 10
runs-on: ubuntu-latest
if: github.event.pull_request.draft == false
steps:
- name: checkout
uses: actions/checkout@v4
Expand All @@ -27,11 +34,12 @@ jobs:
# still using the deprecated types in ibc-go v8
args: --timeout=5m0s --disable staticcheck
- name: test
run: go test -v ./...
run: go test -v ./module
e2e:
name: e2e
timeout-minutes: 45
runs-on: ubuntu-latest
if: github.event.pull_request.draft == false
steps:
- name: checkout
uses: actions/checkout@v4
Expand All @@ -46,5 +54,8 @@ jobs:
run: |
make chain
make contracts
sleep 20
make relayer
make test
- name: integration-test
run: go test -v ./tests -tags dev -ldflags="-X github.com/datachainlab/ibc-parlia-relay/module/constant.blocksPerEpoch=20"
2 changes: 1 addition & 1 deletion e2e/chains/bsc/Dockerfile.bootstrap
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ FROM ghcr.io/foundry-rs/foundry:nightly-462b2ac6c038dc24b8f38b0c59b664d0740604c2
RUN apk add --d --no-cache ca-certificates npm nodejs bash alpine-sdk expect jq curl bash python3
RUN curl -sSL https://install.python-poetry.org | python3 -

RUN git clone https://github.com/binance-chain/bsc-genesis-contract.git -b v1.2.2 /root/genesis \
RUN git clone https://github.com/bnb-chain/bsc-genesis-contract -b v1.2.4 /root/genesis \
&& cd /root/genesis && npm ci

RUN cd /root/genesis && /root/.local/bin/poetry install
Expand Down
2 changes: 1 addition & 1 deletion e2e/chains/bsc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ bootstrap:

.PHONY:network
network:
docker compose -f docker-compose.simple.yml up -d bsc-rpc bsc-validator1-1 bsc-validator1-2 bsc-validator1-3
docker compose -f docker-compose.simple.yml up -d bsc-rpc bsc-validator1-1 bsc-validator1-2 bsc-validator1-3 bsc-validator1-4 bsc-validator1-5
docker compose -f docker-compose.simple.yml up -d bsc-rpc2 bsc-validator2-1 bsc-validator2-2 bsc-validator2-3

.PHONY:network-down
Expand Down
4 changes: 2 additions & 2 deletions e2e/chains/bsc/docker-compose.bsc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ services:
context: .
dockerfile: Dockerfile.bsc
args:
GIT_SOURCE: https://github.com/binance-chain/bsc.git
GIT_CHECKOUT_BRANCH: v1.4.8
GIT_SOURCE: https://github.com/bnb-chain/bsc
GIT_CHECKOUT_BRANCH: v1.4.13
image: bsc-geth:docker-local
4 changes: 2 additions & 2 deletions e2e/chains/bsc/docker-compose.simple.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ services:
environment:
BLOCKS_PER_EPOCH: 20
INIT_HOLDER_BALANCE: "500000000000000000000"
NUMS_OF_VALIDATOR: 3
INIT_NUM_OF_CABINETS: 2
NUMS_OF_VALIDATOR: 5
INIT_NUM_OF_CABINETS: 4
volumes:
- bsc-rpc:/root/storage/bsc-rpc
- bsc-validator1-1:/root/storage/bsc-validator1
Expand Down
967 changes: 528 additions & 439 deletions e2e/chains/bsc/genesis/contracts/BSCValidatorSet.sol

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions e2e/chains/bsc/genesis/genesis-template.template
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@
"shanghaiTime": 0,
"keplerTime": 0,
"feynmanTime": 0,
"feynmanFixTime": 0,
"cancunTime": 0,
"haberTime": 0,
"haberFixTime": 0,
"bohrTime": 0,
"parlia": {
"period": 3,
"epoch": {{BLOCKS_PER_EPOCH}}
Expand Down
607 changes: 0 additions & 607 deletions e2e/chains/bsc/genesis/scripts/generate.py

This file was deleted.

10 changes: 7 additions & 3 deletions e2e/chains/bsc/scripts/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,20 @@ function generate_genesis() {
echo "replace init_holders.template"
sed "s/{{INIT_HOLDER_ADDRESSES}}/${INIT_HOLDER_ADDRESSES}/g" scripts/init_holders.template | sed "s/{{INIT_HOLDER_BALANCE}}/${INIT_HOLDER_BALANCE}/g" >scripts/init_holders.js

echo "replace BSCValidatorSet.sol"
sed "s/INIT_NUM_OF_CABINETS = 21/INIT_NUM_OF_CABINETS = ${INIT_NUM_OF_CABINETS}/g" contracts/BSCValidatorSet.sol >contracts/BSCValidatorSet.sol.out
mv contracts/BSCValidatorSet.sol.out contracts/BSCValidatorSet.sol

echo "replace generate.py"
sed "s/{{BLOCKS_PER_EPOCH}}/${BLOCKS_PER_EPOCH}/g" scripts/generate.py >scripts/generate.py.out1
sed "s/{{INIT_NUM_OF_CABINETS}}/${INIT_NUM_OF_CABINETS}/g" scripts/generate.py.out1 >scripts/generate.py.out2
sed "s/{{BSC_CHAIN_ID}}/${BSC_CHAIN_ID}/g" scripts/generate.py.out2 >scripts/generate.py
sed "s/dev_chain_id: int = 714/dev_chain_id: int = ${BSC_CHAIN_ID}/g" scripts/generate.py > scripts/generate.py.out
sed "s/epoch: str = \"200\"/epoch: str = \"${BLOCKS_PER_EPOCH}\"/g" scripts/generate.py.out > scripts/generate.py

echo "start generate validators"
node scripts/generate-validator.js

echo "start generate process"
/root/.local/bin/poetry run python3 scripts/generate.py dev

}

function init_genesis_data() {
Expand Down
2 changes: 1 addition & 1 deletion e2e/chains/bsc/scripts/bsc-rpc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ done
ETHSTATS=""
geth --config ${DATA_DIR}/config.toml --datadir ${DATA_DIR} --netrestrict ${CLUSTER_CIDR} \
--state.scheme=hash --db.engine=leveldb --verbosity ${VERBOSE} --nousb ${ETHSTATS} \
--unlock ${unlock_sequences} --password /dev/null --ipcpath /gethipc
--unlock ${unlock_sequences} --password /dev/null --ipcpath /gethipc --override.fixedturnlength 2
2 changes: 1 addition & 1 deletion e2e/chains/bsc/scripts/bsc-validator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ geth --config ${DATA_DIR}/config.toml --datadir ${DATA_DIR} --netrestrict ${CLUS
--mine --miner.etherbase=${VALIDATOR_ADDR} -unlock ${VALIDATOR_ADDR} --password /dev/null --blspassword /scripts/wallet_password.txt \
--light.serve 50 --pprof.addr 0.0.0.0 --metrics \
--rpc.allow-unprotected-txs --history.transactions 15768000 \
--pprof --ipcpath /gethipc --vote
--pprof --ipcpath /gethipc --vote --override.fixedturnlength 2
12 changes: 8 additions & 4 deletions module/facade.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,14 @@ func QueryFinalizedHeader(fn getHeaderFn, height uint64, limitHeight uint64) ([]
return queryFinalizedHeader(fn, height, limitHeight)
}

func QueryValidatorSet(fn getHeaderFn, height uint64) (Validators, error) {
return queryValidatorSet(fn, height)
func QueryValidatorSetAndTurnLength(fn getHeaderFn, height uint64) (Validators, uint8, error) {
return queryValidatorSetAndTurnLength(fn, height)
}

func ExtractValidatorSet(h *types.Header) (Validators, error) {
return extractValidatorSet(h)
func ExtractValidatorSetAndTurnLength(h *types.Header) (Validators, uint8, error) {
return extractValidatorSetAndTurnLength(h)
}

func MakeEpochHash(validators Validators, turnLength uint8) []byte {
return makeEpochHash(validators, turnLength)
}
19 changes: 0 additions & 19 deletions module/header_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,25 +70,6 @@ func queryFinalizedHeader(fn getHeaderFn, height uint64, limitHeight uint64) ([]
return nil, nil
}

func queryFinalizedHeaderAfterCheckpoint(fn getHeaderFn, height uint64, limitHeight uint64, checkpoint uint64) ([]*ETHHeader, error) {
var ethHeaders []*ETHHeader
for i := height; i < checkpoint; i++ {
_, h, _, err := queryETHHeader(fn, i)
if err != nil {
return nil, err
}
ethHeaders = append(ethHeaders, h)
}
afterCheckpoint, err := queryFinalizedHeader(fn, checkpoint, limitHeight)
if err != nil {
return nil, err
}
if afterCheckpoint == nil {
return nil, nil
}
return append(ethHeaders, afterCheckpoint...), nil
}

func queryETHHeader(fn getHeaderFn, height uint64) (*types.Header, *ETHHeader, *VoteAttestation, error) {
block, err := fn(context.TODO(), height)
if err != nil {
Expand Down
47 changes: 19 additions & 28 deletions module/header_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ func TestHeaderQueryTestSuite(t *testing.T) {
}

func (ts *HeaderQueryTestSuite) SetupTest() {
err := log.InitLogger("DEBUG", "text", "stdout")
ts.Require().NoError(err)
}

func (ts *HeaderQueryTestSuite) TestErrorQueryFinalizedHeader() {
Expand All @@ -36,60 +38,49 @@ func (ts *HeaderQueryTestSuite) TestErrorQueryFinalizedHeader() {
ts.Require().Nil(headers)

fn = func(ctx context.Context, height uint64) (*types.Header, error) {
header := &types.Header{
Number: big.NewInt(int64(height)),
h := headerByHeight(int64(height))
if h != nil {
return h, nil
}
if height == 31835601 || height == 31835602 {
header.Extra = common.Hex2Bytes("d88301020b846765746888676f312e32302e35856c696e7578000000b19df4a2f8b5831defffb860a44482b16993815ff4903016ce83ef788b455e2c80ba9976e8e55ac6591b9f9965234a0a2c579269bc5e09577977322d07d17bb8d657ac621a1abfadcb35b9c9d4713dbdd3d47fd3cc6dc2475c989aa224fecd083101049ef1adea2718b00e37f84c8401e5c5cfa0be938dfeafe5b932c2dcef0e2bebb1a05f31104a59b49d78b0b7746a483c14648401e5c5d0a03658f0bb6692995a9dd3b72a69ec6e8e1b9af4361718d8a275c2b92d26eeffc28027cb6d065d5a6d8749ca45a185add61b9ce470136898643170f8072513ca45f35d826f02cb2494f857beebdac9ec04196c8b30a65352ef155a28ac6a0057ff1601")
}
return header, nil
return &types.Header{Number: big.NewInt(int64(height))}, nil
}

// No finalized header found ( invalid relation )
headers, err = queryFinalizedHeader(fn, 31835592, 31835602)
headers, err = queryFinalizedHeader(fn, 360, 400)
ts.Require().NoError(err)
ts.Require().Nil(headers)
}

func (ts *HeaderQueryTestSuite) TestSuccessQueryFinalizedHeader() {
ts.Require().NoError(log.InitLogger("INFO", "json", "stdout"))
fn := func(ctx context.Context, height uint64) (*types.Header, error) {
header := &types.Header{
Number: big.NewInt(int64(height)),
h := headerByHeight(int64(height))
if h != nil {
return h, nil
}
if height == 31835601 {
header.Extra = common.Hex2Bytes("d88301020b846765746888676f312e32302e35856c696e7578000000b19df4a2f8b5831defffb860a44482b16993815ff4903016ce83ef788b455e2c80ba9976e8e55ac6591b9f9965234a0a2c579269bc5e09577977322d07d17bb8d657ac621a1abfadcb35b9c9d4713dbdd3d47fd3cc6dc2475c989aa224fecd083101049ef1adea2718b00e37f84c8401e5c5cfa0be938dfeafe5b932c2dcef0e2bebb1a05f31104a59b49d78b0b7746a483c14648401e5c5d0a03658f0bb6692995a9dd3b72a69ec6e8e1b9af4361718d8a275c2b92d26eeffc28027cb6d065d5a6d8749ca45a185add61b9ce470136898643170f8072513ca45f35d826f02cb2494f857beebdac9ec04196c8b30a65352ef155a28ac6a0057ff1601")
} else if height == 31835602 {
header.Extra = common.Hex2Bytes("d88301020b846765746888676f312e31392e38856c696e7578000000b19df4a2f8b5831defffb860a244628caa7b3002a245b677c419c5991d9ba62e7d298e96565b72f8ccc6587510f8827c00783d0a13326bfc72bbcbb90e6bdf988ef662b286158296e0f270f21568fdb75210f631d53b81e74f0fa9a5c591dc46cbeceb28952264d8863b7812f84c8401e5c5d0a03658f0bb6692995a9dd3b72a69ec6e8e1b9af4361718d8a275c2b92d26eeffc28401e5c5d1a06b3b459206a5b6b1963e686318b0261b9c0888e1a253f77d109c60c6734c84c28031c42276b8ebf15bb5b843865147ea9435be29a83afeae646fc156b45832e0016bb3fa7119db6fe5dfe5d99733b6f7dd38ac4d7aeb7882cd4b6c576faf6951a901")
}
return header, nil
return &types.Header{Number: big.NewInt(int64(height))}, nil
}

headers, err := queryFinalizedHeader(fn, 31835592, 31835602)
headers, err := queryFinalizedHeader(fn, 360, 402)
ts.Require().NoError(err)
ts.Require().Len(headers, 11)
ts.Require().Len(headers, 402-360)
}

func (ts *HeaderQueryTestSuite) TestSuccessQueryLatestFinalizedHeader() {

verify := func(latestBlockNumber uint64) {
getHeader := func(ctx context.Context, height uint64) (*types.Header, error) {
header := &types.Header{
Number: big.NewInt(int64(height)),
}
if height == 31835601 {
header.Extra = common.Hex2Bytes("d88301020b846765746888676f312e32302e35856c696e7578000000b19df4a2f8b5831defffb860a44482b16993815ff4903016ce83ef788b455e2c80ba9976e8e55ac6591b9f9965234a0a2c579269bc5e09577977322d07d17bb8d657ac621a1abfadcb35b9c9d4713dbdd3d47fd3cc6dc2475c989aa224fecd083101049ef1adea2718b00e37f84c8401e5c5cfa0be938dfeafe5b932c2dcef0e2bebb1a05f31104a59b49d78b0b7746a483c14648401e5c5d0a03658f0bb6692995a9dd3b72a69ec6e8e1b9af4361718d8a275c2b92d26eeffc28027cb6d065d5a6d8749ca45a185add61b9ce470136898643170f8072513ca45f35d826f02cb2494f857beebdac9ec04196c8b30a65352ef155a28ac6a0057ff1601")
} else if height == 31835602 {
header.Extra = common.Hex2Bytes("d88301020b846765746888676f312e31392e38856c696e7578000000b19df4a2f8b5831defffb860a244628caa7b3002a245b677c419c5991d9ba62e7d298e96565b72f8ccc6587510f8827c00783d0a13326bfc72bbcbb90e6bdf988ef662b286158296e0f270f21568fdb75210f631d53b81e74f0fa9a5c591dc46cbeceb28952264d8863b7812f84c8401e5c5d0a03658f0bb6692995a9dd3b72a69ec6e8e1b9af4361718d8a275c2b92d26eeffc28401e5c5d1a06b3b459206a5b6b1963e686318b0261b9c0888e1a253f77d109c60c6734c84c28031c42276b8ebf15bb5b843865147ea9435be29a83afeae646fc156b45832e0016bb3fa7119db6fe5dfe5d99733b6f7dd38ac4d7aeb7882cd4b6c576faf6951a901")
h := headerByHeight(int64(height))
if h != nil {
return h, nil
}
return header, nil
return &types.Header{Number: big.NewInt(int64(height))}, nil
}
height, h, err := queryLatestFinalizedHeader(getHeader, latestBlockNumber)
ts.Require().NoError(err)
ts.Require().Len(h, 3)
ts.Require().Equal(int(height), 31835600)
ts.Require().Equal(int(height), 401)
}
for i := 31835602; i < 31835602+100; i++ {
for i := 403; i < 403+100; i++ {
verify(uint64(i))
}
}
Expand Down
18 changes: 7 additions & 11 deletions module/header_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@ package module
import (
"encoding/hex"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/rlp"
"github.com/stretchr/testify/suite"
"math/big"
"testing"
)

Expand All @@ -22,12 +20,9 @@ func (ts *HeaderTestSuite) SetupTest() {
}

func (ts *HeaderTestSuite) TestNewHeaderSuccess() {
rawHeader := types.Header{
Root: common.HexToHash("c84307dfe4ccfec4a851a77755d63228d8e0b9ba3345d1eee37ed729ee16eaa1"),
Number: big.NewInt(21400),
Extra: common.Hex2Bytes("d88301020a846765746888676f312e32302e35856c696e7578000000b19df4a2150bac492386862ad3df4b666bc096b0505bb694dab0bec348681af766751cb839576e9c515a09c8bffa30a46296ccc56612490eb480d03bf948e10005bbcc0421f90b3d4e2465176c461afb316ebc773c61faee85a6515daa8a923564c6ffd37fb2fe9f118ef88092e8762c7addb526ab7eb1e772baef85181f892c731be0c1891a50e6b06262c816295e26495cef6f69dfa69911d9d8e4f3bbadb89b977cf58294f7239d515e15b24cfeb82494056cf691eaf729b165f32c9757c429dba5051155903067e56ebe3698678e9135ebb5849518aff370ca25e19e1072cc1a9fabcaa7f3e2c0b4b16ad183c473bafe30a36e39fa4a143657e229cd23c77f8fbc8e4e4e241695dd3d248d1e51521eee6619143f349bbafec1551819b8be1efea2fc46ca749aa184248a459464eec1a21e7fc7b71a053d9644e9bb8da4853b8f872cd7c1d6b324bf1922829830646ceadfb658d3de009a61dd481a114a2e761c554b641742c973867899d38a80967d39e406a0a9642d41e9007a27fc1150a267d143a9f786cd2b5eecbdcc4036273705225b956d5e2f8f5eb95d2569c77a677c40c7fbea129d4b171a39b7a8ddabfab2317f59d86abfaf690850223d90e9e7593d91a29331dfc2f84d5adecc75fc39ecab4632c1b4400a3dd1e1298835bcca70f657164e5b75689b64b7fd1fa275f334f28e1896a26afa1295da81418593bd12814463d9f6e45c36a0e47eb4cd3e5b6af29c41e2a3a5636430155a466e216585af3ba772b61c6014342d914470ec7ac2975be345796c2b81db0422a5fd08e40db1fc2368d2245e4b18b1d0b85c921aaaafd2e341760e29fc613edd39f71254614e2055c3287a517ae2f5b9e386cd1b50a4550696d957cb4900f03ab84f83ff2df44193496793b847f64e9d6db1b3953682bb95edd096eb1e69bbd357c200992ca78050d0cbe180cfaa018e8b6c8fd93d6f4cea42bbb345dbc6f0dfdb5bec73a8a257074e82b881cfa06ef3eb4efeca060c2531359abd0eab8af1e3edfa2025fca464ac9c3fd123f6c24a0d78869485a6f79b60359f141df90a0c745125b131caaffd12b772e180fbf38a051c97dabc8aaa0126a233a9e828cdafcc7422c4bb1f4030a56ba364c54103f26bad91508b5220b741b218c5d6af1f979ac42bc68d98a5a0d796c6ab01b659ad0fbd9f515893fdd740b29ba0772dbde9b4635921dd91bd2963a0fc855e31f6338f45b211c4e9dedb7f2eb09de7b4dd66d7c2c7e57f628210187192fb89d4b99dd4000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000be807dddb074639cd9fa61b47676c064fc50d62cb1f2c71577def3144fabeb75a8a1c8cb5b51d1d1b4a05eec67988b8685008baa17459ec425dbaebc852f496dc92196cdcc8e6d00c17eb431350c6c50d8b8f05176b90b11b3a3d4feb825ae9702711566df5dbf38e82add4dd1b573b95d2466fa6501ccb81e9d26a352b96150ccbf7b697fd0a419d1d6bf74282782b0b3eb1413c901d6ecf02e8e28939e8fb41b682372335be8070199ad3e8621d1743bcac4cc9d8f0f6e10f41e56461385c8eb5daac804fe3f2bca6ce739d93dbfb27e027f5e9e6da52b9e1c413ce35adc11000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ea0a6e3c511bbd10f4519ece37dc24887e11b55db2d4c6283c44a1c7bd503aaba7666e9f0c830e0ff016c1c750a5e48757a713d0836b1cabfd5c281b1de3b77d1c192183ee226379db83cffc681495730c11fdde79ba4c0cae7bc6faa3f0cc3e6093b633fd7ee4f86970926958d0b7ec80437f936acf212b78f0cd095f4565fff144fd458d233a5bef0274e31810c9df02f98fafde0f841f4e66a1cd000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f8b5830aefffb86097bc63a64e8d730014c39dcaac8f3309e37a11c06f0f5c233b55ba19c1f6c34d2d08de4b030ce825bb21fd884bc0fcb811336857419f5ca42a92ac149a4661a248de10f4ca6496069fdfd10d43bc74ccb81806b6ecd384617d1006b16dead7e4f84c8401dd8eaea0e61c6075d2ab24fcdc423764c21771cac6b241cbff89718f9cc8fc6459b4e7578401dd8eafa010c8358490a494a40c5c92aff8628fa770860a9d34e7fb7df38dfb208b0ddfc380ff15abfc44495e4d4605458bb485f0cac5a152b380a8d0208b3f9ff6216230ec4dd67a73b72b1d17a888c68e111f806ef0b255d012b5185b7420b5fb529c9b9300"),
}
ethHeader, err := newETHHeader(&rawHeader)
// 400
rawHeader := fromRlp("f90442a04ec3c90370deeeab62de72108470bccac75d1abe118a778f01afa7a99c976a5da01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948fdaaa7e6631e438625ca25c857a3727ea28e565a08d30abd786d85a8a10ba441afafdf853b7fd2769351f6600402b88a1ac2d4d7aa0015ebe4a5d6cd56f0bf97db1d21746f59ab5cbecf216e34753920d815403ada2a03cd1ebc99cd975182c58de47be968c97658cff4c465e20654185f408a851403cb9010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000028201908402625a008229a884669a6ce9b90223d98301040b846765746889676f312e32312e3132856c696e7578000020155b72048fdaaa7e6631e438625ca25c857a3727ea28e565b94a73be71b4a5703b4d0b36e4f65d52615b668b385efc047f7f385ace378981fa3750a0bc16ca6f8217be599bcfa274a7876ea32e7a748c697d01345145485561305b248cd0ede772633b8baea9958f9b602db36d78934d948244a13c2d66e998f987783276e9aee6facbff50b0d63574406b51b2e42bc54d19116d2348ac83461e2e0915d508ad921ebe99c27c8fdbd30aecdbe86f95aee2e06995f83ebeb327924669629f193ffd3257315c79ed5a4867ec53b502b5e6e04db2de85453e0936b441c339a26d10cfa71b50a50dd5edefbafd33740101d074b6d58b56a787a7644ddfff77d0c00f9e62cc58c931e671afc564f3f6e255cc6fc8a56701f8ae0fb8608b6dc552b410a6fa44fa31643850bcb314f1d4edb32c0c79ee3efef5397691f3685d80057d77510a00e77a39e8b2497419053c3b81a8901e85590a20a0a2dad529c82f6c175ec3ebca8a9112415aa94718af673c16c0e90e327e27709666e499f84882018ea0709f88597f05218c198818991cf5598c9280db30d5bfe899da9b7a8c963bff6c82018fa04ec3c90370deeeab62de72108470bccac75d1abe118a778f01afa7a99c976a5d8012518315e9c22a4a648f4d26efcf57f877a26498de6d53fe7a267e8d5ef01482009817fc9de90ca8008ef1f420aa606ddc0c56a975bace3906601fd5cde657d600a0000000000000000000000000000000000000000000000000000000000000000088000000000000000080a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b4218080")
ethHeader, err := newETHHeader(rawHeader)
ts.Require().NoError(err)

accountProof := []string{
Expand All @@ -45,12 +40,13 @@ func (ts *HeaderTestSuite) TestNewHeaderSuccess() {
target, err := header.Target()
ts.Require().NoError(err)
ts.Require().Equal(target.Number, rawHeader.Number)
validator, err := ExtractValidatorSet(target)
validator, turnLength, err := extractValidatorSetAndTurnLength(target)
ts.Require().NoError(err)
ts.Require().Equal(len(validator), 21)
ts.Require().Equal(len(validator), 4)
ts.Require().Equal(turnLength, uint8(1))
ts.Require().NoError(header.ValidateBasic())
ts.Require().Equal(header.GetHeight().GetRevisionHeight(), target.Number.Uint64())
account, err := header.Account(common.HexToAddress(ibcHandlerAddress))
account, err := header.Account(common.HexToAddress("aa43d337145e8930d01cb4e60abf6595c692921e"))
ts.Require().NoError(err)
ts.Require().Equal(account.Root, common.HexToHash("c3608871098f21b59607ef3fb9412a091de9246ad1281a92f5b07dc2f465b7a0"))
ts.Require().Equal(account.CodeHash, common.Hex2Bytes("7498e14000b8457a51de3cd583e9337cfa52aee2c2e9f945fac35a820e685904"))
Expand Down
Loading

0 comments on commit 10eaeba

Please sign in to comment.