diff --git a/common/config/config.go b/common/config/config.go index e738470f..45f75107 100644 --- a/common/config/config.go +++ b/common/config/config.go @@ -113,6 +113,10 @@ var ETH4345_HEIGHT = map[uint32]uint64{ NETWORK_ID_MAIN_NET: constants.ETH4345_HEIGHT_MAINNET, } +var ETH5113_HEIGHT = map[uint32]uint64{ + NETWORK_ID_MAIN_NET: constants.ETH5113_HEIGHT_MAINNET, +} + var HECO120_HEIGHT = map[uint32]uint64{ NETWORK_ID_MAIN_NET: constants.HECO120_HEIGHT_MAINNET, NETWORK_ID_TEST_NET: constants.HECO120_HEIGHT_TESTNET, @@ -145,6 +149,11 @@ func GetEth4345Height(id uint32) uint64 { return height } +func GetEth5113Height(id uint32) uint64 { + height := ETH5113_HEIGHT[id] + return height +} + func GetEth1559Height(id uint32) uint64 { height := ETH1559_HEIGHT[id] if height == 0 { diff --git a/common/constants/constants.go b/common/constants/constants.go index 1fb90494..4cf02949 100644 --- a/common/constants/constants.go +++ b/common/constants/constants.go @@ -56,3 +56,6 @@ const POLYGON_SNAP_CHAINID_MAINNET = 16 // eth arrow glacier upgrade const ETH4345_HEIGHT_MAINNET = 13_773_000 + +// eth gray glacier upgrade +const ETH5113_HEIGHT_MAINNET = 15_050_000 \ No newline at end of file diff --git a/native/service/header_sync/eth/header1559.go b/native/service/header_sync/eth/header1559.go index f8ec817f..3a98ea9a 100644 --- a/native/service/header_sync/eth/header1559.go +++ b/native/service/header_sync/eth/header1559.go @@ -254,6 +254,14 @@ func isArrowGlacier(h *Header) bool { return h.Number.Uint64() >= forkHeight } +func isGrayGlacier(h *Header) bool { + forkHeight := config.GetEth5113Height(config.DefConfig.P2PNode.NetworkId) + if forkHeight == 0 { + return false + } + return h.Number.Uint64() >= forkHeight +} + // VerifyGaslimit verifies the header gas limit according increase/decrease // in relation to the parent gas limit. func VerifyGaslimit(parentGasLimit, headerGasLimit uint64) error { diff --git a/native/service/header_sync/eth/header_sync.go b/native/service/header_sync/eth/header_sync.go index 1460c0ee..63b45dfb 100644 --- a/native/service/header_sync/eth/header_sync.go +++ b/native/service/header_sync/eth/header_sync.go @@ -171,7 +171,9 @@ func (this *ETHHandler) SyncBlockHeader(native *native.NativeService) error { //verify difficulty var expected *big.Int - if isArrowGlacier(&header) { + if isGrayGlacier(&header) { + expected = makeDifficultyCalculator(big.NewInt(11_400_000))(header.Time, parentHeader) + } else if isArrowGlacier(&header) { expected = makeDifficultyCalculator(big.NewInt(10_700_000))(header.Time, parentHeader) } else if isLondon(&header) { expected = makeDifficultyCalculator(big.NewInt(9700000))(header.Time, parentHeader) diff --git a/native/service/header_sync/eth/header_sync_test.go b/native/service/header_sync/eth/header_sync_test.go index 5b92a5db..f12e2b0e 100644 --- a/native/service/header_sync/eth/header_sync_test.go +++ b/native/service/header_sync/eth/header_sync_test.go @@ -345,6 +345,60 @@ func TestSyncBlockHeader(t *testing.T) { } } +func TestSyncBlockHeaderGrayGlacier(t *testing.T) { + ethHandler := NewETHHandler() + var native *native.NativeService + tx := &types.Transaction{ + SignedAddr: []common.Address{acct.Address}, + } + isTest = true + { + header15_049_999, _ := hex.DecodeString("7b2262617365466565506572476173223a223078373337623735323937222c22646966666963756c7479223a2230783332636139643335633466356231222c22657874726144617461223a223078653462383833653562646139653761353965653462623939653962316263343832643231222c226761734c696d6974223a22307831633963333830222c2267617355736564223a223078616262303633222c2268617368223a22307835666530376636303461366666303261623238396638636564353330316461653232373331303464663333303262363364306332316238656565646136663735222c226c6f6773426c6f6f6d223a2230783635663130663261343532646438643266636130353238396632373133633637303031626631303234663136333263363630353138353230313430343139313166383934633963646236346331323331356230303561366363663639343139323162353563303231636639383363386466633631303230343030663665303433363133303536383833393230623530633662343330323538353539306432363731313132363635633863646335303435336361396265353063393435396132346465636436633438333265663464666235313438316534383134653830653239353230343531653530613138326434343064393433643935313365393834313037393834633163303538333764643634613036653763363535313834363434363463353732316531333365316334353931343332366363303431353033383235396634326166333363353832366634653830656165356531653330663034393032396336633236323336333039336333343562363237346435363261383330326335623065653065343230663161373464633638386132313238326537623134376261303333636433326165303831633038653166396336663865313663303033386637653030383939306531623837303134306266386334333234646363303834623032383431653963633038663034303663623964393461323062386562222c226d696e6572223a22307838323962643832346230313633323661343031643038336233336430393232393333333361383330222c226d697848617368223a22307861313038386664306161323436303239623935323731396636386539633431633166346166653332653732646661343233316636356631376331633765313832222c226e6f6e6365223a22307831333632346462303964646539323530222c226e756d626572223a223078653561353066222c22706172656e7448617368223a22307861613637343863306666636538653238313462303563636331386665323832616238363739313038373930626362386261656561326361393531336235313836222c227265636569707473526f6f74223a22307866323931663665626365356232313433306139303739666430333038316431386239666135323366623235636163393633333133366236356232616333303838222c2273686133556e636c6573223a22307833326263316664626232623533646337393264373532393931386338356232343334333734633638343235663036623364323138633561303366316431373134222c2273697a65223a2230783132626131222c227374617465526f6f74223a22307837336663336538356663373031623535363533636664653231393866626235633935393834366530616338376666313639376638346234396431313134653130222c2274696d657374616d70223a2230783632626438306332222c22746f74616c446966666963756c7479223a22307862333531306235636236656235343234663964222c227472616e73616374696f6e73223a5b22307862383536316335643433366435306534383339636163366431306238303537626433656138313531376330646166313838303234653936323364363436623533222c22307833643863313638373166336461346366346465353936396335316134316234383337313433636432613536376133626563343136636666653835393261326635222c22307865323731323565343438343337303035396362663134653364326363333238336361326331653839336266313736323962633933396466393066353964353637222c22307834303761303635393536393632336535623835323539336664396234373731646265336336636365336332333461343132333165383634663663623033303731222c22307832643734363735643031663633353334616433663038376566366437373635643032653066636135376162396136333039346631386130333832326639366237222c22307862363364626165633635396434313036356435356436333236316136316135613664663565616164363136666664343362356163643865353839623635353634222c22307866356161626434633335636665393737373866653435393634633262396535626365323539643566353632366162366531326334633930653631303265353030222c22307838356537646438323630346635633530386564366231613461636533336231343333653566626134313039316538383231386464383632643838346531363264222c22307830666162363131353963323230613536653036323863316261306537643964316536363865363061616336386364356333623835396530383233623733613562222c22307838646130323666653436383339316635383431376362346233313435333031353133393730323065613931353637376463383931383637656632616239366136222c22307862333634393565343966653935616538343133363934366265313233663335326132393661343666633334323935646465646363303735303566663639356539222c22307861343539366536356632313132356639646366366333393333323231623431363938663563393362623066343733313634363866326333316339613363653735222c22307837393966356562346465383935303963616564373831633566613531353064636261393334306337313537376230666532353465646636333036633065356338222c22307866306130376436663137363436643934333863393635383163336662313866623639613064623632666233663162386230623234653564313431376330306432222c22307839636239383831666634366434633636643062613266306438336139356663326435613566376565326638306162653634373363356432643761373334626163222c22307866306462303561383833373466633364393036306365333535613333343335306666306539363564356630646234383634653034356366323333633639396537222c22307837623561623830373134663733323937653061353666633663653534646464333066303831623961343137336436633331366537376437663862623134303838222c22307835646136363365353936646639313165333936626334393837316636366661313635623737643231623538363739346162643634386663613837333836336566222c22307833366666343464393863666633323433666338656363663665383530666162666564633634653261633861393637386165636632326239343861396234616138222c22307839346666383436623764636332653039303030376236636233316163393635653033353166303638616531613165653166653666386638383164643562326531222c22307834373665636562343338313265323531306430383235376230353162393237346663363039333238666562386364646338326435336362633063633262653364222c22307838666234623131356437336265306439633663646265376138353536646435316663373334623664366131373963363038646433656362623239306432616434222c22307833303665613330306432363766313532656462343432306439306631366266363038643261663330353738373763383338623364303562356638363034393763222c22307861646564396262616262303335323237313537366137363566393232343133353861386131313234383034323337343537303434343936396464616535353533222c22307832356465323265633135363235306333333537396632313232643438313937336639373062366439623161636631323462623862616335383738323131613138222c22307834376534656432336630613663623836366232303837343933616135363863326161363463663836393066346363633531366238623735306134623536353865222c22307865663236313639376333336434353362396235383764353530323564343738666661656462643566333431643331363061333935323265336431623162613933222c22307832646563383063323736383865376161376534336134636533323932656434393831616334613962653763306138656539333266613566666234663962636665222c22307837383162613736623464313231313537353437643133396233396237383233326533633039356532356136343738396131303631333863393639333636386136222c22307863383066613963663539353338663863626336363633333433653265333233316561326561613665323862633036666266333636646664326162623630316632222c22307864303331636436313963613437656561633836326237363237333265303662306539623235363739333331666631643637366535623736336234386463653131222c22307866636362373233393639343436356562663564656664326162393038656437336166386566623937633832386561613235363039656563636439303362633138222c22307862353363373039393139373866346530656464323536626464356432646236323363383333346637616432623433313431636162303539623765343662356536222c22307865303463643665343839636339336162353162363232373330613438633437396561303866663638336537353036626362356637383434643461623839326633222c22307835366332396365316163626464353735646536373838373934303634366566643135643237333561303539363864636162663838303735636135306235653563222c22307863633434653534363430373464643935613230373063306438636133623466313562666536363530336266333634316663663033653365633238633634663934222c22307832336237313232656438316638393666653738333066633666656433363633616638616261663236343262306634333437383430323739636435323864613637222c22307861383731623435616563643630616362643066323965646333383230303831343336313263656333373338336564613331653338613130353566393837643433222c22307864396261323034353934633631616232373934353031636233386465653035643738346235376161346535616262636233363166396130393230356531343861222c22307831383832323333626433643139376438306233643465343139623837633762323761393536303435316133316665316262396139643938663535623832626531222c22307863333766396664613865663537326162316366333463633966343633613063363731643461353862623834333638633932636463653961393337653636663366222c22307830613561346131643564313866396436353530626436326361646433393366616662376562333533613239303061386137323761353137363063316331663631222c22307832616630636230356531363936383330353066346435653466363330623639656134633061326261363963663763306638396635383635653961343937343866222c22307836393533363030643434333531366331363039376563623563333830376561363161383566613431303436626335346336323034623464656430346637346662222c22307831373463336333363936643835666366373438396438376662383266643133336439663837336563613639393864633464653335303561663330373537613435222c22307863313835363664306361633065316636326262343466633533656433353666656232383735383964343939376536323961323437313264393830663634613635222c22307861346462653065626364393538646338636164306665623631366239306464386139663734613137623661353761316333383930346363323835663635383738222c22307863303435366466323531646234383039616636356434613664663039373166386566366165396465343666353661316366336137636231383133646566643331222c22307839383862333633386163306263356230393562663164623439376461643965333630623464613664393938633563323938366438316435356365623561653933222c22307831626238303539343630396465353463373630353735326330353931656137363636353439623036313664386134623436343232656330353336363362373031222c22307836326430656464613761306335353334313937396438666661643465363662343166663136623433306336333061303262396333636361656333356238353231222c22307864386266303139353166383230373736356637326230316335393766626336393233383034646634316166303736313762303662623962646431643331386366222c22307864636533353764613134646163316237613661303132343836656564356337616436663566663666356437306235323732366264356266396435373835643438222c22307834636330346432343731636539333636343965326433313631633230373832356532383537346635643862333434303635373038373031613439376234636363222c22307864636530633236306161303236316265383837666531333531646435633961313062373032373335656332353735663632643764356263366234386139313766222c22307830373831656364356633363537383437373534663562656431363535333261636231613631306566613034643464373634373536383436613932613664383563222c22307834616165343630646362663365303738383936336531326230633962333863396432643931646662343562626333336165306638643735666366373831356363222c22307863633265326231396662356562303139353937323339616330393761396365336639663961386535626663636238393631383362363230333735393336643431222c22307836323730666438386463333461616462633538396231366666373364353334356661393133323763356435343532323663306530653038376234623663633630222c22307832343532356633376563336338636564316366623464333465626162333161666365363939613337336235613766316636636135306337613137336332376264222c22307839383236326530353264663061633131653738323966366532316562633461643931383630363566623663323036306239616166343266663436623839396166222c22307861393237343466323836313437333335353262383663356562333736363963323331383233303632636637373431623665613938303961663737343531336237222c22307866373065346661303336313338363364643531643938343965363734383132346130323537326437623132376237363430383261343461373566326631386264222c22307863616531366435623466316565396637326435636462386535613830393731353637376431313061313334623932313463383839636365343132396237383938222c22307833656138653735393165613437313762333239303161383365336436653561343331613864333837326634656338386433313062303534636131343936623030222c22307863323561393064366265333633353665326437393263393363336434356136366565663538373137376132653962326631343033326339643331626463346361222c22307866306633373939353437303230643838623965366435373266393735663865323031616461303164633130356265383730646130333638346432643136333664222c22307838353433366335373832306230313263666238643831623339333766376535333233323964316135613636366134316266333230363032653332353030626438222c22307834646166616138383365633038653634363731656633646562346661626163626432636439373530623436623864313366383539333139633535366430336665222c22307835383535343864653632323861633232643264323133356533353835373463323237396233383466643765373662316564623631396438356166386234306161222c22307866356263643534306537396337356263363630393164626435376430663539633164656537303739356539343736663933643463323366303938323133653431222c22307864303335363161336431306338386131343233353966313939616266303166323366366536383835646163303832363737393032633464393238376465386530222c22307836366434303633646161666439353233383966336564633139373430393930353438343166636332313138623139303739386466366162383066323032656239222c22307865323035343133336361386563353366366566656333663563343239333037303265613135653838363162393863646164303636383166623336636432643036222c22307866653366373632663063656662303961313864613037393566366634653931396232623266303639353766613830356434653234653435373265613432333035222c22307837316163313961376164616264636335323233373334643531366666383566666662383235653635663765393865363761323231363634653930306366346161222c22307861383237356535306530626264343732643938316532353535346632333961303464636431353465653536343863376163643036386331623862316138613431222c22307836333737626239613933343264656361353735393339633337373165313566643733376333633061353837333933353965626537326538373863623264663931222c22307838666165326432643035333461336630396332333265313339393663393237393338626131656230306363363632613939663737336461653136353837323332222c22307861353662353563646531383732633536626465303963373237646166366632663265386332636231633330643932613736623036366461363034643462653166222c22307864666364373034623630373165366463346462666234323762343461346535376266626364616230626266316466363961666366363764393162666164343437222c22307861663732636237636134636561656165623535643732373164393333636236333561663635326234323064666663313465353430633534646664633632393035222c22307838306539663734323832343234613936303835333965663365326163393132313537353837323632636666333338623032366631313539303439346631666233222c22307866663638636137346561316661643363383632633464623161306335373362386231356533333837613332396461623436363363376135383334383361363964222c22307864643933613830363365316539633132636536613137336564366439383735396237373362623130666535376136376565353438386237323938666336353435222c22307834363230666561623063363562663232303738633961313430376562363864636331663362366631636538363335373435623635363830313231396362376363222c22307831323636393739343938633737613935616132303630343134626462623439363235333334336332373462626330373039636166353735383031343462356662222c22307833656564316238376437323932363264393837316431393766636161343534383761353437386362316631383530353637383334333138336165396435656639222c22307836346663623139353639313661643434326335383661313031653136346635323030383366633365623730376535666132383137626539653138663035353932222c22307865313938353963643036343565393135376332373836343662376163333035666339633039316130316435623539636136396435383166353432623434316563222c22307865363233613039386539656331643562646366623864373161623436613635366161633164623761336566356165623464313731633137323030633532653731222c22307832373735366338366136346439626664353535383335366361353466666137616539396334636463303265303234326362376364346136626432353332363565222c22307830613238386466626564356234343465653334643665353463356536313135383862363531356161666438366533306463323064326665326635616164386638222c22307866633236393361386330663731376434633833303634303039626261313531356532353537386531373165313933363764623734313731386564633265313136222c22307865333034336366623031363364633736393937626430373439363936316531363039666163326532303265326638383762306139396331313766646432393238222c22307831353035373165303736663933636664323734326237663237386561326265663466376261643938353263326232363335383262326336353463383338356661222c22307838373261323636316161306361313131313566623537626133646134643531366135633130326466616630353136626638636137633539353233623264333562222c22307836613766666130666439663462663538656337313137636361383835353963653365643361393137386666643835336637333335323961323063333266363636222c22307866633666396262313564306133626535623834313437666563646533393261373432366239303636626332623536316266333634343134393936383764623061222c22307864616338343831363963363236663164333138326333393961616539646137333630393763623730643063376135383736336631633861363531353231393938222c22307832326466363337393666363933306165616337386332623165313737616334313063303531626638396661336536646561653332343737613266633464356366222c22307836613439323437656536643037363436353831353636656261333364333738613239326131333462333236356434643463386135386162303537396330393166222c22307832323133393366346366363266643935316137326138316264643563663363353061636463356438623766343330383863386234626333393138333836346364222c22307863393636616335376664653361623037396263636562646665323139306139386363643136323661336335633536313731363561306439626262363066393134222c22307861326231663461363664626330356230366162353535323035303138396466353964373532636538666437303038323665373838396633643434346535363634225d2c227472616e73616374696f6e73526f6f74223a22307862636132633465333163306538393561633832386132643730643862646631326232663163633839333432363237626130653263333733346437326439336339222c22756e636c6573223a5b22307838316235373030343831353263646263373930333435626465646531363462346136393234633633323333323337386437626365633863613664323163623466225d7d") + param := new(scom.SyncGenesisHeaderParam) + param.ChainID = 2 + param.GenesisHeader = header15_049_999 + sink := common.NewZeroCopySink(nil) + param.Serialization(sink) + + native = NewNative(sink.Bytes(), tx, nil) + err := ethHandler.SyncGenesisHeader(native) + assert.Equal(t, SUCCESS, typeOfError(err)) + height := getLatestHeight(native) + assert.Equal(t, uint64(15_049_999), height) + header10499400Hash := getHeaderHashByHeight(native, 15_049_999) + assert.Equal(t, true, bytes.Equal(ethcommon.HexToHash("0x5fe07f604a6ff02ab289f8ced5301dae2273104df3302b63d0c21b8eeeda6f75").Bytes(), header10499400Hash.Bytes())) + } + { + header15_050_000, _ := hex.DecodeString("7b2262617365466565506572476173223a223078366665303062623764222c22646966666963756c7479223a2230783332643066613839366261653466222c22657874726144617461223a2230783730366636663663363936653265363336663664323161323037616338316333383064353532222c226761734c696d6974223a22307831633935313131222c2267617355736564223a223078336362356562222c2268617368223a22307863343364333566366136346638613634663034366338646562343036393537326436323264666537663032386636323330316231383666303866306539366632222c226c6f6773426c6f6f6d223a2230783030323930313030303538303138303031303231303036323931313130373630363131303030343031303434313030306130303031303030313630303030383130303062333130303030303032303831343038303938303130343030303130303032383838303030303830323338303438373030343231303030333232303030303035303030303030303030303032633638303630303439303032303461323130313830303034323064343133303030363063303063343938323632303034303032303430303032306130613438393030303034323030303034323030383530303035303032303030343030303530343838383030303130303030383032303030653030383132303032343230306330303430633035303030303230343030303434323138346431326230303134303830313230303034303638353430303830386131383031303131303236363430343361383436343930306430383038613830303034303230303032323030303033303036303036303430303039303830323030313038363232343034303038303030383139303030323831313066303030303836303030343031303030303031383030303030393032303830323238303030303332323030383061303030303030303030383134306134623863303830303830303030303038343032613930343032383632303030303030373833303833222c226d696e6572223a22307832613230333830646361356263323464303532616366626637396261323365393838616430303530222c226d697848617368223a22307864366661643335623930353130306563333066616263666337353163343165653162646162653231373632303863356162393366323934643463366133323530222c226e6f6e6365223a22307832313235303535333131646137303163222c226e756d626572223a223078653561353130222c22706172656e7448617368223a22307835666530376636303461366666303261623238396638636564353330316461653232373331303464663333303262363364306332316238656565646136663735222c227265636569707473526f6f74223a22307833383634646134373833333136303931313935656263656235343733396237313134646566313534383261636138626236383534313330363334343432623763222c2273686133556e636c6573223a22307831646363346465386465633735643761616238356235363762366363643431616433313234353162393438613734313366306131343266643430643439333437222c2273697a65223a22307833396164222c227374617465526f6f74223a22307832303931386135343365326634343439303762353136613261343336653638396534363437373936663131393631646434373436383239643036373766393037222c2274696d657374616d70223a2230783632626438306363222c22746f74616c446966666963756c7479223a22307862333531306538396336393365616466646563222c227472616e73616374696f6e73223a5b22307861663861386133313032323235323036313762376636303238356661316135303531333539666661373866393965346463323262316236333036623336373734222c22307837326132653339346166383164656230666636383265363639636261613238386232663362653439356235313766666635366233623765643230663238653964222c22307835643939646362666130363761306234623034393637633262363233613663656331343138353565666536663663353462373465653335663338343131623733222c22307832336139376462306366396335393331306463363135316231333764633936396331626435373134393137316565646639366363633835313366333930613966222c22307863393735643363363833623966643461393737306232633232386133643438666365303836343762643532396464646565383464613063626331346339663764222c22307835336138616363323030343936336339623533376464383434636661386636373263663239373532636535633836663233336434663331643136656561666662222c22307832393262633436333934616138613733636564353065623764333835343234663562323562323565313361613961656432323065663263386462336338633333222c22307837333639636230633835386462333161623539336463383138303333386530656338646165303130396436366463643866386235616365326334383563336638222c22307861363938383335303433393432396537373565396635373666653831666335306330386262353364386236653862623134376230326466643831653337636238222c22307832613366616438613039303337383363353739366538383866346163373436376130313033623165313339643433633263333363303430393962303963636265222c22307864633131313033373666343664343763666636633763386231393433636666333136396663333038656366336539393262636137353263303531323264356264222c22307863393436333733653935363562356234623238343162623836656662643737663234313561323432363163363033386337393936613836386132393962623466222c22307838373837643937326532393830323163373438376364636338656437343233323564356365346566333235353130356462333130346133383232313662323937222c22307861613134366135623964656162353737636239373235666266336633366663613664636431663630326438613631653862386332356665663830616261343530222c22307866376335613637623138396464393365336232383534646331633132313936303037376262616461373638353338613762356236616165393238376133393637222c22307862656166333463626636613635313863643562623237393136366563363038346337626330333334313635376364366662366131386230653832313130386266222c22307862613365323031323963343162653830363431353861386261306463336563373330343463386439393436306665323661313063386638353335303737646434222c22307865393230636437376632623663613734656235323530303536373266626331626234356363356365616437356331306262336664306161326435666531643139222c22307866306132376264653433353762336431623538623531363134386334323739633431313562636363306566633330356263363664336532653830363935386330222c22307864646531373138346430366432623334303133346136396661366263623935666135616362356633653138383662383531326132306338373139323065366536222c22307836393335393230636138303563383832363363633861346137323263323138623065323432613261346361376363373933636237343131303466633665326532222c22307835333265356431303766666234343337333061363438346664313561663236326337653763636135393466396362666463646535633064353964376561646664222c22307835646364643930326463383665613231663166666239326263626432633965636364383534393763653036326366613934663732653630393934653365646539222c22307862633761393639623631303561346166363963383163623436393761343938373432653133346461343361633631333765646537643964646339383830396235222c22307834323163643136366236303031366361373862643536376430373537336364323733623136633631646662643662323436326665326139323363336436656164222c22307835396261366264353230626561366463643039633633633266386133386631356532343335653035313561626133323339663730663765633466613332343533222c22307832363938643765353534653236343037643262643462653539643536346664323361313736616165323230326139623466376261363932663033333533313534222c22307835336139376164323162633734393861393563663965333862623132386530346166326335613663303436313130613138393966383762346235633463646164222c22307862666566336562666164666335316566643839323463636234386436306166623565363162373936333161373262303536326239636563363535646430313264222c22307865613066343166346630613161306663336330316563326534633834386563313036306331616636376634383838623036313061623432376231323632386131222c22307863613962633134636238633565313630616162633664333936373464366536613833353331343132383336343439643639333435373565646663626161373037222c22307834333265306237306138646663323732343564373337396361343261633465363361653632323565333834636366643361303664643732386337313465363830222c22307834396665623463356132623431666236353164373763323663373261383664626364376132616134376562373837646233386233386232666437396237626561222c22307863383230663136393863323330356365343730303338353435366437326532336538353131323163616636656133623132663630333834623534333831613662222c22307839303137646562323935633762313365313335386539626165323666373234643434373638633634623735633833626533303633383837663439636262386239225d2c227472616e73616374696f6e73526f6f74223a22307839363831623436376466306238623939386637353932656465373666343163313336663937313834626531653563653737306465343431613536373065306363222c22756e636c6573223a5b5d7d") + + param := new(scom.SyncBlockHeaderParam) + param.ChainID = 2 + param.Address = acct.Address + param.Headers = append(param.Headers, header15_050_000) + sink := common.NewZeroCopySink(nil) + param.Serialization(sink) + + native = NewNative(sink.Bytes(), tx, native.GetCacheDB()) + err := ethHandler.SyncBlockHeader(native) + if err != nil { + t.Fatal("SyncBlockHeader", err) + } + assert.Equal(t, SUCCESS, typeOfError(err)) + height := getLatestHeight(native) + assert.Equal(t, uint64(15_050_000), height) + + header15_050_000Hash := getHeaderHashByHeight(native, 15_050_000) + assert.Equal(t, true, bytes.Equal(ethcommon.HexToHash("0xc43d35f6a64f8a64f046c8deb4069572d622dfe7f028f62301b186f08f0e96f2").Bytes(), header15_050_000Hash.Bytes())) + header15_050_000_formstore := getHeaderByHash(native, header15_050_000Hash) + h := new(Header) + err = json.Unmarshal(header15_050_000, h) + if err != nil { t.Fatal(err) } + headerBytes, _ := json.Marshal(h) + assert.Equal(t, true, bytes.Equal(header15_050_000_formstore, headerBytes)) + + } +} + func TestSyncBlockHeader1559(t *testing.T) { ethHandler := NewETHHandler() var native *native.NativeService