o1-labs / o1js

TypeScript framework for zk-SNARKs and zkApps
https://docs.minaprotocol.com/en/zkapps/how-to-write-a-zkapp
Apache License 2.0
520 stars 118 forks source link

Mina.fetchActions returns an empty list of actions when endActionState is defined #1426

Closed dfstio closed 3 weeks ago

dfstio commented 9 months ago

On Berkeley testnet, calling

let actions = await Mina.fetchActions(publicKey, {
      fromActionState: startActionsState,
      endActionState: endActionState,
    });

returns an empty list when endActionState is not undefined. It works as expected when endActionState is undefined.

This behavior is the same on minascan and minaexplorer endpoints.

The test code: https://github.com/dfstio/merkle-map-demo/blob/endActionState/tests/actions.test.ts

The test code log:

merkle-map-demo % yarn test actions
[2:39:11 PM] number of all actions: 12
[2:39:11 PM] lastActionState: 4671254814962134621561188624509467899566137729694462218629375270473276286241
[2:39:11 PM] number of actions starting at startActionsState: 6
[2:39:11 PM] actions starting at startActionsState: [
  {
    actions: [ [Array] ],
    hash: '2889372988449481232750872203377957230274508842265070242272487645409136733839'
  },
  {
    actions: [ [Array] ],
    hash: '15147297301450527213667297732587033679468451271733367936786243634936439048634'
  },
  {
    actions: [ [Array] ],
    hash: '5766519161874551854426173362531259652853737507928229135738402350087629707642'
  },
  {
    actions: [ [Array] ],
    hash: '3472596428023171912405119750508284466233959846144065437966752178811252259985'
  },
  {
    actions: [ [Array] ],
    hash: '5072649747128810814145361414529837940474819464966837380953978607528499679008'
  },
  {
    actions: [ [Array] ],
    hash: '4671254814962134621561188624509467899566137729694462218629375270473276286241'
  }
]
[2:39:11 PM] number of actions starting from startActionsState and ending on lastActionState: 0
[2:39:11 PM] number of actions starting from startActionsState and ending on endActionState: 0
 FAIL  tests/actions.test.ts
  Actions
    ✓ should get all actions (499 ms)
    ✓ should get actions starting from startActionsState (138 ms)
    ✕ should get actions starting from startActionsState and ending on lastActionState (172 ms)
    ✕ should get actions starting from startActionsState and ending on endActionState (163 ms)

  ● Actions › should get actions starting from startActionsState and ending on lastActionState

    expect(received).toBeGreaterThan(expected)

    Expected: > 0
    Received:   0

      67 |         actions.length
      68 |       );
    > 69 |       expect(actions.length).toBeGreaterThan(0);
         |                              ^
      70 |     } else throw new Error("actions is not an array");
      71 |   });
      72 |

      at Object.<anonymous> (tests/actions.test.ts:69:30)

  ● Actions › should get actions starting from startActionsState and ending on endActionState

    expect(received).toBeGreaterThan(expected)

    Expected: > 0
    Received:   0

      81 |         actions.length
      82 |       );
    > 83 |       expect(actions.length).toBeGreaterThan(0);
         |                              ^
      84 |     } else throw new Error("actions is not an array");
      85 |   });
      86 | });

      at Object.<anonymous> (tests/actions.test.ts:83:30)

Test Suites: 1 failed, 1 total
Tests:       2 failed, 2 passed, 4 total
Snapshots:   0 total
Time:        2.097 s, estimated 3 s
Ran all test suites matching /actions/i.
dfstio commented 9 months ago

See also https://github.com/o1-labs/o1js/issues/1427

MartinMinkov commented 9 months ago

Thanks for creating the issue! I'll try to reproduce this week and see if a fix can follow ASAP.

dfstio commented 9 months ago

It is a minascan log from https://api.minascan.io/archive/berkeley/v1/graphql archive node:

  actions(
    input: {address: "B62qjirMYUSyjb1AcyNmAF5dLqTk3KQuoUYKv5FGdx618GDmRfYNAME", fromActionState: "15883099431178491989573353483798785787585407519424468142944726203792446252042", endActionState: "5766519161874551854426173362531259652853737507928229135738402350087629707642"}
  ) 

response:

{
  "data": {
    "actions": []
  }
}

It seems that o1js sends the correct query, and the problem is on the archive node side.

dfstio commented 9 months ago

I also see many "Failed to derive correct actions hash" errors when sending and fetching 64 actions.

It seems like the expected hash is incorrect, and it is related to the https://github.com/o1-labs/Archive-Node-API/issues/7 This error goes away after 40 min for 64 actions and after 2 hours for 128 actions.

The log: ``` Error: Failed to derive correct actions hash for B62qmWinDr5Z6mNTLhrmYJaVpT5VkAvzPj2yNMpgvZW2tG7ecVcNAME. Derived hash: 5087414236753245201930380039048228093583476748337714816313279364943871421152, expected hash: 18269893881838629284331648658679092092437978667735050852390565156830431977871). All action hashes derived: [ { "actions": [ [ "37", "2868791761771209925312580147951213731224064270950492234768436571247378146850", "1", "13221503620354851164539602174418709505877666383811859858625088218510149105700", "15756764610870658780042553301432911215433404154921169963612106952011145231353", "1", "2" ] ], "hash": "26059775457197520998216310707686216260492012982514338260780466253535904601271" }, { "actions": [ [ "9", "9994195482170887932617944732726656050810611221299027604773634123402063211066", "1", "22946166790834645845811338960099296960076659916580079270369197110386812339859", "5240076959438931180354941239894828917064541055139339646434664466027413012715", "1", "2" ] ], "hash": "10330304804228781026446971113510383077110700049788886142076000151799585874299" }, { "actions": [ [ "64", "16052902792968309734312939442729560384335475801588177354289522140957299456485", "1", "24245239025001217183017768622778046067917044897069764958617469766517275259577", "15781417673533796873915200847848456442313961938648209224505640495679153192018", "1", "2" ] ], "hash": "28220940228236747194867137193330886034052492886219893176856280689376669909399" }, { "actions": [ [ "5", "14291571277450576819428153460009267969046552592628109455662337304658371207884", "0", "20724617211367755382332723006928473657030925144707642992045832146638857128725", "12273138682217141991297343142031018957580326862379111154519613827961907431461", "1", "2" ] ], "hash": "276759031921892644140536115856297465164743669228463231298476275740751406258" }, { "actions": [ [ "34", "10187723560574950563293150116123411150865416803830285547827801200768994633974", "1", "13438242713562940251935179634751669001560483954826646836873470934015040376763", "10747356509800126255743237790041030766449041226304121127051734294889252849854", "1", "2" ] ], "hash": "4155684205850482554062738943168670170045478506329793556943562587418544539862" }, { "actions": [ [ "54", "19504717683163937659972139374843770557645294133757594982353293680776797817024", "0", "18931976605260820567693938056750650660563811892404710541080293416481064063668", "15506197485244843144771263771783669746617553605166609443970311512589146260116", "1", "2" ] ], "hash": "10097405937028634234531009831981303716320441768589313170259698255656679677560" }, { "actions": [ [ "15", "19774643583894099092696459322646478249815035765837024555991847071200970421875", "0", "999162329000090735063832913626944057021902329705062991935482863906694057403", "16260548158380024831610660290639681749527027282344976121144547176623621331657", "1", "2" ] ], "hash": "27120826872645146772010132723982449019138915952110075899519533731101499259822" }, { "actions": [ [ "17", "6281188956397821037759663160072754819717948239061529070377545886897432933885", "1", "3712316338471682449098310879118327237293621162894721809648692830887924762464", "9375655901414123672136857991243539187577477923254107425589875250655213008899", "1", "2" ] ], "hash": "17622138261843843113021738164909420308007835139780446449614116054347012319120" }, { "actions": [ [ "18", "14257263724753908259161734578647196775320913168962950953229487343978799559046", "0", "14672477237029191636986892527015265530550819966566375418023589955978849871574", "3840576495647555898237357037218882754611135676769505413398777750230417685100", "1", "2" ] ], "hash": "21180855412484225889363083923764448379024334085142797912506054168730808499947" }, { "actions": [ [ "44", "9960810088904267252583964496806445920712755162585184674611993643654346891484", "0", "14806897360473707005889717213801152705761244626835490632713810943877162640932", "2806720112907894675340948146216630851274723126509773454090631226140559539781", "1", "2" ] ], "hash": "2223442532698346614092082952768934638835378134529541761828229692214521973447" }, { "actions": [ [ "24", "8579888175586969454275225162340728831087404074252079014937680152214841478989", "0", "6584383253315571822468452733512659537801967044577463019098454238278517156349", "22695380959401613994651111718556334160219328692179459206700634605242876880172", "1", "2" ] ], "hash": "5891010396161311447797211696023421182948594512913093158335736565775626071327" }, { "actions": [ [ "60", "5916126796891635250894467113481096283351322953290261919213182336370623083712", "0", "13081022495620614248566404622615279388799737735492630425043946815795625073484", "20323118568876803560266122517963649983761246139182696040822891868512471680849", "1", "2" ] ], "hash": "12328873565887374392798852515681779234870174499452920735395854033749543255649" }, { "actions": [ [ "42", "19093192140225338143755612608058914004941842381164742268210606188089492307561", "1", "15383618155812282357149434416435130338431820496247611194666485695357748258530", "7840791981067369277981840050348243423832980250435984464096148551842011211055", "1", "2" ] ], "hash": "20057611069398838814622356530442755237869680752816206389505594435777701462348" }, { "actions": [ [ "61", "7732314447719996736908190953212516188175752861507358392678301787819588791182", "1", "26038329757350123278740928900249182100646080356808758267532595138938759801313", "28604957808633837244119588727901818538823635049244995620088715158519363664874", "1", "2" ] ], "hash": "1239446176116008975566128146441885628045159581004107702340217950979880243046" }, { "actions": [ [ "32", "4500723665239728678130901996619701836457273702140856823967250100891386759893", "0", "22092527268194238737792763440665930353615986977521771196608152506706407128516", "18414415966611408314135736598323616759501485383138548120081656671277975294707", "1", "2" ] ], "hash": "25307034140889010329232742621104662757116724877841495716006156013826512763382" }, { "actions": [ [ "40", "21170453486929169087875564239316487749144867668182660769812917924610984131231", "1", "11373158176752978048127761542105800292495824176920179031984352533217560996472", "14805657415175059986044947808587749562087341600822069329105923154097632560248", "1", "2" ] ], "hash": "28913457344816472737624036740863392143050294946470170463286743091714820229252" }, { "actions": [ [ "21", "8391978530124160781957461342156415584981537647073677154857581877860578825563", "0", "17261041724064395582265854036683615888228786900292643139966482451217014574205", "20887187330163054381686185900298825922731604414477416743264339028403264793274", "1", "2" ] ], "hash": "27352710517494754143205568569326485723455175921432528517542152357532929205605" }, { "actions": [ [ "7", "20638093391536706552563301034400698149709584862273047092561010885228621410758", "1", "22093510699556003618435457554938999774362162452735854690947408605559563203245", "1420672552860197585068601306134387097812425209905104527960291367660632488536", "1", "2" ] ], "hash": "8572456845611600659509016288085187493670437764205019459333015739070506544166" }, { "actions": [ [ "38", "4975021582082367192647198052301676045323737231804885150635231026517031089929", "1", "18185073411217891705141377145129685354955721019651009523349796732040617890201", "28192817586109339650481240474291176149047429879968171786221606934937134875109", "1", "2" ] ], "hash": "1430782078928499463566469929618791593500098043369633673621322472370016085359" }, { "actions": [ [ "6", "7472566563847016735563112109983284432516166397808838678413783263077926627353", "1", "27878264692588608945454025319508815850659547320785282676789437362157555249156", "24174679190224653586498409960754770970549622029030497188628231449996240654892", "1", "2" ] ], "hash": "14530965892120132377129002586824256013586284555962219339825340087195993947918" }, { "actions": [ [ "12", "11576643422416522672055796115215806154948919878910851204828677783839537766558", "1", "28788993568256885417736530918224628146270630464036772836489966555138709908283", "5948191207503368253369446468301704032829305152268372250324949446714548695352", "1", "2" ] ], "hash": "5167165033243538108324977082554127393002011787735718041255646647819968927679" }, { "actions": [ [ "57", "8635519852393778519447299630278752106135833884687683772511114665039473212225", "1", "19808480748958217236974464081394063497210538678937981067371050787008609503885", "22805069572976193726256645644799076442212313804887104473134907610832584276716", "1", "2" ] ], "hash": "8223558430052093324462993552731157571520605625884502708677051359993258707694" }, { "actions": [ [ "19", "10307156352087962239070434066522135287803895490812432703886726270704521808221", "0", "19722027271394139428295457201029714046178189506379040709133557911952669450809", "15883639899008148700327872519457991693461392389180138743558121141652895256762", "1", "2" ] ], "hash": "11785906157702180786002140702287881123319157845375412873417561226004822785471" }, { "actions": [ [ "23", "24644680725452184633359645521712181408821163977003431789562061545518103292972", "1", "9535702373417999858665661635437976310513885372953005899059876633741474761620", "14410429194564097235243779130908365555532104877222318769361014769363409613726", "1", "2" ] ], "hash": "11084648537166873458115935115949460987482069170428581876659532084409124250197" }, { "actions": [ [ "49", "5004232838158238981397507099648020171469046318864978334848756990037548614669", "1", "22681529947822610196160293263421244679006045595586333086574081281425945113308", "6273175596569342252986947724388008739831218879325931275162397390577532812186", "1", "2" ] ], "hash": "19124481827424750527856187679353873675843350531139871997486927015087350138922" }, { "actions": [ [ "27", "20496516931846423631796299972088625343814851331496997162446373562634449066932", "1", "20042141082912796042835635771022118461237908918006459164133223891304552580066", "1437435800395931381308959744871298497064180915039075128244790632575791106868", "1", "2" ] ], "hash": "19865214388230218040251271214958460904924028927116739185914235569050860820157" }, { "actions": [ [ "4", "14608686494208735395843984252470074652216813454386200642762177054154246348384", "1", "3469944378661952945671979188983783302925608988485066691985683561939673957471", "20179584123141792364000193954947074864683663276412950012786914464228806734937", "1", "2" ] ], "hash": "17531234168081321931817817559236701446095356034100477760220197707833463587387" }, { "actions": [ [ "55", "18930948275036574621977570040431143502931807566780916524583511089219010793976", "0", "14324795054354854682718908169509724597427088045533240251030322433938844230895", "20174383922663651780606982629640890387557617769044449665811016441701004235481", "1", "2" ] ], "hash": "699295207277261375421560954527495080848743874946144558744257092260946852496" }, { "actions": [ [ "11", "534461720489841589550466416492130402375094318415498799472389277540588026814", "1", "26963511203160979497385540163256571438098974695235829578462857983562670568481", "2486162260789818787304693794873743293509024915567528189571945743924995079321", "1", "2" ] ], "hash": "28565108713306749905120554563148796157436196253577984214012156202092488089039" }, { "actions": [ [ "30", "10489209049483667297008507603884583971333932927355398130810812749869567336954", "0", "13772582110787826542352448963914572702806207024154134598790255090883047972574", "4964599330960854137876295928581875222571561719705986456037892530246475882290", "1", "2" ] ], "hash": "1508259474856515767034362003332972798010875121062614213671240779180495600290" }, { "actions": [ [ "20", "9491914965171476986074895669135522902151999556277324395057854363868956801337", "0", "21425073955994625807105121704718855270321226417064032672060586652061668957768", "10886891427918434498526430030782088810290618213589554977461690127232518650671", "1", "2" ] ], "hash": "3587206210110438953698802833558523819462316412864071587839735334692266596438" }, { "actions": [ [ "33", "10342985663276745176330388517622918279997510215646238677555856204872912380179", "0", "10035212782866047356885420075858419762345682522110531714212521187514413869", "26487952358241004091201061694063300434635561795609134665992565400196173342064", "1", "2" ] ], "hash": "3108003816253290964509111323082813209223725099704712019361465974309195557457" }, { "actions": [ [ "25", "24487750023511894789985782910056679412132811904134563807962813604364444146733", "1", "27297255865336402757127382969069132025595586172372349823314360532719150048071", "21926565786337657261756877951046568495035655900309444695177201525159123772079", "1", "2" ] ], "hash": "4816225286976595740586790771266743304684016137341876532496830395378547956899" }, { "actions": [ [ "8", "19704080997490253478070444129182650526330238451183351524561226757952537025235", "0", "12898338603859289991951691189865854350508865787259355812710530750355256749850", "9993609841704949724949659873766584739276558223910764152849684503295602990346", "1", "2" ] ], "hash": "14067652821603872126008706683870815010345156985629109558899553776714660938830" }, { "actions": [ [ "3", "25170091965796025418512608534871831999521585414538293928328603164547670100683", "1", "17681567119546953682609614261585651946950093625210935401928435536701035250029", "21300756548068105367126199368524257816395513542712235055294832106861818362273", "1", "2" ] ], "hash": "28590080687178047667202309231647177363174917136969986930518326053824987987143" }, { "actions": [ [ "52", "1277306952308799860609209909463293406399431709858791235707674804369849210685", "1", "17164354331696995750103806466590390763592574635873577806547940345536191328825", "16494590256997935478887064753092048083627187883474103176170812518781527474403", "1", "2" ] ], "hash": "18551914232640736946874071609356590892042923201962945024256266929395819193081" }, { "actions": [ [ "45", "13600742810354963877878753943356432553354986542367618261627568295075611607437", "1", "24187360589560258873377026526982247269835848148765282078888207972089441664377", "13512367894477342774735436435371744273254958213528273669965516346043249829795", "1", "2" ] ], "hash": "3211975023788651284907085145027762242463060311630781724784015788625618601839" }, { "actions": [ [ "16", "10812057339424850369150310590766159770990841249717214006120209625515398018847", "0", "19945660650380366923750558999496364376083292612676072474325007913539085368196", "27712450132927024071957227143107069679916452229624277011929443903013286385849", "1", "2" ] ], "hash": "4059960147405180791745727968930571284944676695638690651292914420522573677227" }, { "actions": [ [ "56", "11778086510396682128349167090870337280708326957013289144343026313439285405737", "1", "16732892987757388298666755441397172201295861477066537262293064345933947020630", "26071985909424452034045375754574242129593428719548539612048756957077922926195", "1", "2" ] ], "hash": "21861425228896262019223449565343244619096464493350215469071013757901454002706" }, { "actions": [ [ "62", "23489677724878626933345233797786526991612872377473671988577822325340398157661", "1", "7912414620867899655431778153889131541466680915609873934859233018835062856015", "15676946040881538436007539749938237789053283745175324254153398863578917762460", "1", "2" ] ], "hash": "17215533858996008755165589047880894775217783523764310116172670492027037777464" }, { "actions": [ [ "63", "19736683568299671909586026508973457458935419540453334929939711279322028825643", "1", "12891133810955463952361918235098721076194476051269969544855047597462325510194", "11783512742301942022079584151056240193063792051900623990923117297080572578122", "1", "2" ] ], "hash": "13097206227969699367752978280696724327460978656757496777085870999883296941145" }, { "actions": [ [ "50", "10442639700181240322866377494715726754103289365755916202818845603582307445309", "1", "18605561728264198795056239538394784324729002096205889519007493612685045389169", "5927039414687113713192354230163177853809725535976573742178776353257984874243", "1", "2" ] ], "hash": "18838605265963805035601815727051121581800885529244811935648675143611225072097" }, { "actions": [ [ "26", "159000649571376937292733268606149653373461073607997761140292568051320439581", "0", "26447020547324474111604548935995166790606299065271622878373548506782454648500", "1027176135851206764744152721997506404174218808771656985177923413514620379378", "1", "2" ] ], "hash": "220807196692309776426246568916378018667576615733866844702836662562732122672" }, { "actions": [ [ "39", "19771533040271916064580408924215466160613750181334973401922700046635715978882", "1", "25992909870038635330302835159219546771768088333777532649410321843749904336644", "7644641606262760916835613543620315775336398304490989346437845631066629700074", "1", "2" ] ], "hash": "9527178833326845471390769508658348696767241773961649342323652691113983902758" }, { "actions": [ [ "31", "9128177641251275876223593665892862281140754483447534392836516711193545556999", "0", "2198990515776480253208619981757690485836592159650326242522067772457645121935", "55986178634508507839608001101966237054432044402005317908955528205989914246", "1", "2" ] ], "hash": "17814031656363500021212375317146888221253726644331425138359625303962091181546" }, { "actions": [ [ "58", "5241910022961006748847151198098321475911555624846013790253023274613827720129", "1", "8086204329014949488511287601785435000146515773868381565880860534342983562971", "17868367367100341867391572595712966009827646233360008781101630454921452887766", "1", "2" ] ], "hash": "3989069825373227011534784386691696707466936953702883758485877197067368805834" }, { "actions": [ [ "51", "18501580269170244784813920691616834567926379624904120562010237634959034515744", "0", "24008236298302096371164178545489181043484899637170102220490129824440580903206", "322171767821457071874485087914778726513013568193962718908597870953477235610", "1", "2" ] ], "hash": "24418632000799182483264904830101541235073089161490984876482136393401965093121" }, { "actions": [ [ "48", "2718735259303754144368242196351633704202795945518235853554263217236863654594", "0", "28851688868564526328490524783098107057709787218413051633666842229093000215585", "9285752086994652719503161087538827181314474576605541600896906407994698886856", "1", "2" ] ], "hash": "10461871361924385047367236351429023107638919376372816318340900585859684754227" }, { "actions": [ [ "14", "14186312972270938555211316864234218158252387802486504296404732485077565204994", "1", "16771334816404405067380819569663639808965006817760393750781053218165199687032", "16662172025423042907932963648912662096633101969607122730395390232079163206915", "1", "2" ] ], "hash": "24569364191815174517799230008069487774782968819623438753760725640556454412070" }, { "actions": [ [ "46", "19749255848971612429890904516911976250560661653601257746641068078229693665703", "0", "11282216170305824719359468102839941012682209736245958589163862738406427083767", "23355892155837391176395717343572081673862469287471327206949270140412683603294", "1", "2" ] ], "hash": "24265685809737329354035004726197825425512077370785104120101273262807295687239" }, { "actions": [ [ "22", "16746435097798290388281988440282317560374777015016014845621971263577829294348", "1", "21807919440268732975968462671631572456754281931210314212042911470898929258856", "13877551199649453226727738012829638971735850574454443443545377279875846556644", "1", "2" ] ], "hash": "19042983962524322158812699963454769743738762742487357895889788871113916945612" }, { "actions": [ [ "47", "18058082805048380742533319703205131446486092088280723107986247634290538068605", "0", "8040268096842735967414565024220228167089739737928845470756828870877511970243", "24861265202653715182190499914689551706106986556177483798587835366119644787433", "1", "2" ] ], "hash": "3352835333230393244733178296372044928797142791379681435047507735926634367909" }, { "actions": [ [ "10", "7369240064192204999170854972341061975714587478708373800566089109849031816272", "0", "18949875248741064421571532767436520106561389690026665130677853051753801768216", "28519810808520675242820744319713546389887177081356147696749083150199878412378", "1", "2" ] ], "hash": "25280709490927525371872503349648466134437406935602525523964795908124169620196" }, { "actions": [ [ "1", "3500112228015401884009765303996831077054875818796748487646063482580422290596", "0", "18724049676558251037882627832341656330407443311087415474670662651681434039802", "7742467102558502807449524799142804050061607375019149023950573978280054729971", "1", "2" ] ], "hash": "11819851929028047476127629634227466985200615419940042027532165784636395215643" }, { "actions": [ [ "28", "25733555225143397412965637547849268403442031770732851085800520202021441898635", "0", "10465236778581948827844174403100632423438650983886922882818901169600755352387", "9929499826591352799756896493198082010981725319502529651665706476805640711910", "1", "2" ] ], "hash": "2617397731065012417025245497404210349584083375677426101595472343970076187119" }, { "actions": [ [ "41", "8963791295917434172199551629892353432392640881530208183104648803388600151063", "1", "6143614751201852514797448576913598669737114836059796997241485699438631432927", "25801205727208799802889691897194885434810437185997154800183027301717048699400", "1", "2" ] ], "hash": "27950988905608572682720797781174051252508063602828162785935915984110207856911" }, { "actions": [ [ "36", "3770620632134552227104454386835654766444195036540992457557949652917027555983", "1", "13922288416833439304340554686064366459690651115569265952903242450651379594520", "4513916634222290079275263726308360293748135363412022926311570738014473715168", "1", "2" ] ], "hash": "13811301792408491204998004004065907507864636841184807555740921661758878355623" }, { "actions": [ [ "29", "5200034551095262237891919171924933346093423239782480491118412932531261534054", "0", "3673253641015625147685634410946865909766969324992435245102867032103864735771", "1006827925702769088121624465326658582890065632276694595736544054466679549372", "1", "2" ] ], "hash": "16131976392397485254130955897149283350819504761993404485920919696670397647397" }, { "actions": [ [ "53", "22852745670858751354363255529273125155218832137276070277278511301827642851713", "1", "24961010889378100037136002649935339263706471068944375369576536970104323242542", "4665627166952638593097010159661419979055387575326233477108316594812481516573", "1", "2" ] ], "hash": "2779573826199882768495674968398014028887511590374910402611818686393219742357" }, { "actions": [ [ "1", "9237648080207879434481382642423943161827834379695395284830800649652891434987", "0", "976373963205816821072323816134345200713327174606542450853335704023356237188", "18711378732613886353145670539215908680426851025369442178271202827150311186332", "1", "2" ] ], "hash": "6519041226661791219474741651464623859831206612895627882494571896842700589267" }, { "actions": [ [ "13", "15257100038793102334766298779728313255815766194313395657441528349763946568305", "1", "17854400666735853916085946985305393889475866428404053289730959653353806274758", "19201849809602992207031912084479909766437807611934201458989999632347783263914", "1", "2" ] ], "hash": "1467634962239578027977105504391953117439534831952638412635188949862128214580" }, { "actions": [ [ "35", "1583531986523731343660428361632403439532912318407712817443820597612316153385", "1", "1837980646587433157242513623486435162495417258783530219003592306696518008010", "6614266844541187873099964874894129676908729995251747434855563514830188315975", "1", "2" ] ], "hash": "20769712945721914234153610899784493850801123862745901478972297657163699453582" }, { "actions": [ [ "59", "1329135760404764002630091073791017637491460999981074920573494379714821112445", "0", "11201848444264235682166638644721638884132113593342188429284970432239335558866", "17143211379879289135262504699588952522775791035461622177976795325064822345966", "1", "2" ] ], "hash": "18843319797278667533661173600698121933053021881723943275544961790885246566519" }, { "actions": [ [ "43", "16435506944592469412861254414119175755559313232151578132467863560636129291490", "1", "22326982204646113819928064783504961285931246647856326158270493425434622153713", "2595230656453761047699083826644727052937659535844456536748085214887119865629", "1", "2" ] ], "hash": "5087414236753245201930380039048228093583476748337714816313279364943871421152" } ] ```
MartinMinkov commented 8 months ago

I did some testing on my end using the zkApp Lightnet, posting some results here for others to read.

The SQL for getting actions with endActionState defined seems to be working okay, I don't think it's an issue with the SQL itself. Dispatching actions and specifying fromActionState and endActionState works on my end. The Archive Node API will return an empty list if either is not present in the Postgres DB when executing the query.

This means the issue can possibly be as you pointed out, it can be due to a bug with how https://github.com/o1-labs/Archive-Node-API/issues/7 was implemented. The issue is probably something as follows:

The Archive Node API uses the Archive Node Postgres database to get all action data recorded from a Mina daemon connected to the network. As blocks are produced and gossiped at the best tip of the network, the Postgres DB will have multiple blocks showing as the best tip. The Mina daemon has consensus logic to determine the best chain, and the Archive Node tries to use the same reasoning to decide what the best tip block is.

What might be happening is that the best tip block between the Archive Node API and the Mina daemon do not agree, which leads to incorrect results. This means fixing the consensus logic in the Archive Node API.

I have a WIP PR here: https://github.com/o1-labs/Archive-Node-API/pull/102

dfstio commented 3 months ago

See also https://github.com/o1-labs/o1js/issues/1775