├── .github └── workflows │ ├── coverage.yml │ └── go_test.yml ├── .gitignore ├── .gitlab-ci.yml ├── LICENSE ├── Makefile ├── README.md ├── block ├── block.go ├── blockcandidate.go ├── blockdatafactory.go ├── blockdatafactory_test.go ├── blockv2.go ├── blockv2_test.go ├── blockv2i_test.go ├── cache.go ├── cache_test.go ├── errors.go ├── handlerv2.go ├── manager.go ├── manager_test.go ├── manageri_test.go ├── reftracer.go ├── syncer.go ├── test_test.go ├── transition.go ├── unsafefinalize.go ├── version.go └── version_test.go ├── btp ├── btpblock.go ├── btpblock_test.go ├── builder.go ├── builder_test.go ├── digest.go ├── digest_test.go ├── digestfrombytes.go ├── digestfrombytes_test.go ├── ntm │ ├── dsam.go │ ├── ethmodule.go │ ├── ethmodule_test.go │ ├── iconmodule.go │ ├── iconmodule_test.go │ ├── module.go │ ├── module_test.go │ ├── proof.go │ ├── proof_test.go │ ├── secp256k1dsam.go │ ├── secp256k1dsam_test.go │ └── secp256k1proof.go ├── proofcontextmap.go ├── proofcontextmap_test.go ├── sectionbybuilder.go ├── sectionfromdigest.go ├── stateview.go └── storage_test.go ├── chain ├── base │ ├── blockhandler.go │ └── platform.go ├── chain.go ├── config.go ├── gs │ ├── database.go │ ├── genesis.go │ ├── pruned.go │ └── writer.go ├── imports │ └── servicemanager.go ├── platforms.go ├── regulator.go ├── resultstore.go ├── revertible.go ├── taskbackup.go ├── taskconsensus.go ├── taskimport.go ├── taskimporticon.go ├── taskpause.go ├── taskpruning.go ├── taskreplay.go └── taskreset.go ├── client ├── clientv3.go └── jsonrpcclient.go ├── cmd ├── cli │ ├── admin.go │ ├── debug.go │ ├── genesis.go │ ├── genesisstorage.go │ ├── helper.go │ ├── keystore.go │ ├── rpc.go │ └── server.go ├── eetest │ ├── eetest.py │ └── main.go ├── gochain │ ├── icon.go │ └── main.go ├── goimpl │ └── main.go ├── goloop │ ├── icon.go │ └── main.go ├── gstool │ └── main.go ├── resetchain │ └── main.go ├── txgen │ ├── call.go │ ├── coin.go │ ├── deploy.go │ ├── main.go │ ├── token.go │ ├── txgen.go │ └── txpool.go └── wsclient │ └── wsclient.go ├── codecov.yml ├── common ├── address.go ├── address_test.go ├── atomic │ ├── cache.go │ └── cache_test.go ├── blockinfo.go ├── cache │ ├── byteslice.go │ ├── costerlru.go │ ├── costerlru_test.go │ ├── costerrandom.go │ ├── costerrandom_test.go │ ├── lrucache.go │ └── simplecache.go ├── clock.go ├── codec.go ├── codec │ ├── bytes.go │ ├── chain.go │ ├── chain_mp.go │ ├── chain_rlp.go │ ├── codec.go │ ├── codec_test.go │ ├── msgpack.go │ ├── rlp.go │ ├── typed.go │ ├── typed_test.go │ ├── typeddict.go │ └── typeddict_test.go ├── codec_test.go ├── compress.go ├── consensusinfo.go ├── consensusinfo_test.go ├── containerdb │ ├── arraydb.go │ ├── arraydb_test.go │ ├── common.go │ ├── common_test.go │ ├── dictdb.go │ ├── dictdb_test.go │ ├── keybuilder.go │ ├── storestate.go │ ├── storestate_test.go │ ├── valueimpl.go │ ├── valueimpl_test.go │ ├── vardb.go │ └── vardb_test.go ├── crypto │ ├── crypto_test.go │ ├── hash.go │ ├── key.go │ ├── key_test.go │ ├── signature.go │ └── signature_test.go ├── db │ ├── bucket.go │ ├── codedbucket.go │ ├── context.go │ ├── database.go │ ├── database_test.go │ ├── databasewriter.go │ ├── databasewriter_test.go │ ├── go_level_db.go │ ├── layer_db.go │ ├── layer_db_test.go │ ├── map_db.go │ ├── null_db.go │ ├── proxy_db.go │ └── rocks_db.go ├── errors.go ├── errors │ ├── errors.go │ └── errors_test.go ├── hexbool.go ├── hexbytes.go ├── hexbytes_test.go ├── hexhash.go ├── hexint.go ├── hexint_test.go ├── intconv │ ├── bytes.go │ ├── bytes_test.go │ ├── int.go │ ├── int_test.go │ ├── string.go │ └── string_test.go ├── ipc │ ├── connection.go │ ├── connection_test.go │ ├── server.go │ └── server_test.go ├── json.go ├── legacy │ ├── block_v0.go │ ├── loopchain.go │ └── loopchain_test.go ├── log │ ├── filter.go │ ├── formatter.go │ ├── forwarder.go │ ├── log.go │ └── writer.go ├── lzw │ ├── reader.go │ └── writer.go ├── merkle │ ├── builder.go │ ├── builder_test.go │ └── copy.go ├── mutex.go ├── signature.go ├── signature_test.go ├── string.go ├── trie │ ├── cache │ │ ├── branchcache.go │ │ ├── cachelist.go │ │ ├── cachelist_test.go │ │ ├── cachemanager.go │ │ ├── fullcache.go │ │ ├── nodecache.go │ │ └── nodecache_test.go │ ├── config.go │ ├── mta │ │ ├── accumulator.go │ │ └── accumulator_test.go │ ├── ompt │ │ ├── autorwunlock.go │ │ ├── bench_test.go │ │ ├── branch.go │ │ ├── bytesobject.go │ │ ├── bytesobject_test.go │ │ ├── extension.go │ │ ├── hash.go │ │ ├── leaf.go │ │ ├── manager.go │ │ ├── mpt.go │ │ ├── mpt_build_test.go │ │ ├── mpt_test.go │ │ ├── mptforbytes.go │ │ ├── node.go │ │ ├── rlp.go │ │ └── rlp_test.go │ ├── trie.go │ └── trie_manager │ │ ├── manager.go │ │ ├── manager_ompt.go │ │ └── manager_test.go ├── txlocator │ ├── manager.go │ └── manager_test.go └── wallet │ ├── keystore.go │ ├── plugin.go │ └── wallet.go ├── consensus ├── bitarray.go ├── bitarray_test.go ├── blockpartset.go ├── bpmcache.go ├── btpblock.go ├── commitcache.go ├── commitcache_test.go ├── commitvotelist.go ├── commitvotelist_test.go ├── consensus.go ├── consensus_test.go ├── doublesigndata.go ├── dsmlog.go ├── fastsync │ ├── blockfetch.go │ ├── client.go │ ├── client_test.go │ ├── fastsync_test.go │ ├── heightset.go │ ├── heightset_test.go │ ├── manager.go │ ├── message.go │ ├── message_test.go │ ├── server.go │ └── server_test.go ├── internal │ └── test │ │ └── networkmanager.go ├── message.go ├── message_test.go ├── misc.go ├── partset.go ├── partset_test.go ├── patch.go ├── patch_test.go ├── signedbase.go ├── step.go ├── syncer.go ├── testwal.go ├── votebase.go ├── votelist.go ├── voteset.go ├── voteset_test.go ├── wal.go └── wal_test.go ├── doc ├── .vuepress │ ├── config.js │ └── hometags ├── README.md ├── btp2_extension.md ├── btp_extension.md ├── build.md ├── genesis_storage.md ├── genesis_tx.md ├── goloop_admin_api.md ├── goloop_admin_api.yaml ├── goloop_cli.md ├── icon_chainscore_api.md ├── icon_config.md ├── iiss_extension.md ├── jsonrpc_v3.md ├── metric.md ├── package.json ├── tutorial.md └── yarn.lock ├── docker ├── base │ ├── Dockerfile │ ├── build.sh │ └── update.sh ├── build-deps │ ├── Dockerfile │ ├── build.sh │ ├── go.Dockerfile │ ├── java.Dockerfile │ ├── py.Dockerfile │ ├── rocksdb.Dockerfile │ └── update.sh ├── function.sh ├── gochain-icon │ ├── Dockerfile │ ├── build.sh │ ├── run.sh │ └── update.sh ├── gochain │ ├── Dockerfile │ ├── build.sh │ ├── run.sh │ └── update.sh ├── goloop-icon │ ├── Dockerfile │ ├── build.sh │ ├── icon_genesis.zip │ ├── icon_governance.zip │ ├── multi.sh │ └── update.sh ├── goloop-java │ ├── Dockerfile │ ├── build.sh │ ├── multi.sh │ └── update.sh ├── goloop-py │ ├── Dockerfile │ ├── build.sh │ ├── multi.sh │ └── update.sh ├── goloop │ ├── Dockerfile │ ├── build.sh │ ├── multi.sh │ └── update.sh ├── lcimport │ ├── Dockerfile │ ├── build.sh │ ├── icon_governance.zip │ ├── run.sh │ └── update.sh └── version.sh ├── go.mod ├── go.sum ├── icon ├── batch.go ├── blockv0 │ ├── block.go │ ├── block_v01a.go │ ├── block_v03.go │ ├── blockvote.go │ ├── blockvote_test.go │ ├── common.go │ ├── lcstore │ │ ├── forwardcache.go │ │ ├── leveldb.go │ │ ├── mergedb.go │ │ ├── mergedb_test.go │ │ ├── nodedb.go │ │ ├── store.go │ │ └── tpsregulator.go │ ├── leadervote.go │ ├── receipt.go │ └── reps.go ├── blockv1 │ ├── blockpatcher.go │ ├── blockpatcher_test.go │ ├── blockv1.go │ ├── handlerv1.go │ ├── handlerv1_test.go │ ├── patch1.bin │ └── patch2.bin ├── build.mk ├── callhandler.go ├── chainscore.go ├── chainscore_basic.go ├── chainscore_btp.go ├── chainscore_iiss.go ├── chainscore_test.go ├── contractmanager.go ├── governancehandler.go ├── icconsensus │ ├── bpp.go │ ├── consensus.go │ ├── consensus_test.go │ └── fastsyncer.go ├── icdb │ └── bucket.go ├── icmodule │ ├── constant.go │ ├── context.go │ ├── enablestatus.go │ ├── enablestatus_test.go │ ├── errors.go │ ├── errors_test.go │ ├── penalty.go │ ├── penalty_test.go │ ├── prepevent.go │ ├── revision.go │ ├── revision_test.go │ ├── types.go │ └── types_test.go ├── icsim │ ├── config.go │ ├── context.go │ ├── doublesign_test.go │ ├── env.go │ ├── event.go │ ├── extramainprep_test.go │ ├── iiss4penalty_test.go │ ├── platform.go │ ├── prepcountconfig_test.go │ ├── receipt.go │ ├── revision.go │ ├── setbondrequirementrate_test.go │ ├── simulator.go │ ├── simulator_test.go │ ├── simulatorimpl.go │ └── utils.go ├── ictest │ ├── blockv0gen.go │ ├── fixtureoption.go │ └── node.go ├── iiss │ ├── base.go │ ├── base_test.go │ ├── calculator │ │ ├── calculator.go │ │ ├── calculator_test.go │ │ ├── iiss3.go │ │ ├── iiss3_test.go │ │ ├── iiss4.go │ │ ├── iiss4_test.go │ │ ├── module.go │ │ ├── prep.go │ │ ├── prep_test.go │ │ ├── statistics.go │ │ ├── statistics_test.go │ │ ├── type.go │ │ ├── voter.go │ │ └── voter_test.go │ ├── calculatorholder.go │ ├── context.go │ ├── context_test.go │ ├── eventlog.go │ ├── eventlog_test.go │ ├── extension.go │ ├── extension_test.go │ ├── extensionlog.go │ ├── iccache │ │ └── nodecache.go │ ├── icobject │ │ ├── bytesimpl.go │ │ ├── factory.go │ │ ├── factory_test.go │ │ ├── object.go │ │ ├── object_test.go │ │ ├── storestate.go │ │ └── storestate_test.go │ ├── icreward │ │ ├── bonding.go │ │ ├── bonding_test.go │ │ ├── btp.go │ │ ├── bugs.go │ │ ├── delegating.go │ │ ├── delegating_test.go │ │ ├── iscore.go │ │ ├── iscore_test.go │ │ ├── object.go │ │ ├── snapshot.go │ │ ├── state.go │ │ ├── state_test.go │ │ ├── voted.go │ │ └── voted_test.go │ ├── icstage │ │ ├── blockproduce.go │ │ ├── blockproduce_test.go │ │ ├── btp.go │ │ ├── commissionrate.go │ │ ├── commissionrate_test.go │ │ ├── event.go │ │ ├── event_test.go │ │ ├── global.go │ │ ├── global_test.go │ │ ├── iscoreclaim.go │ │ ├── iscoreclaim_test.go │ │ ├── object.go │ │ ├── snapshot.go │ │ ├── state.go │ │ └── state_test.go │ ├── icstate │ │ ├── account.go │ │ ├── account_test.go │ │ ├── accountcache.go │ │ ├── accountcache_test.go │ │ ├── allprepcache.go │ │ ├── allprepcache_test.go │ │ ├── blockvoters.go │ │ ├── blockvoters_test.go │ │ ├── bond.go │ │ ├── bond_test.go │ │ ├── commissioninfo.go │ │ ├── commissioninfo_test.go │ │ ├── delegation.go │ │ ├── delegation_test.go │ │ ├── issue.go │ │ ├── issue_test.go │ │ ├── jailinfo.go │ │ ├── jailinfo_test.go │ │ ├── migrate │ │ │ └── unstakedata.go │ │ ├── module.go │ │ ├── networkvalue.go │ │ ├── networkvalue_test.go │ │ ├── nodeownercache.go │ │ ├── nodeownercache_test.go │ │ ├── object.go │ │ ├── prep.go │ │ ├── prep_test.go │ │ ├── prepbase.go │ │ ├── prepbase_test.go │ │ ├── prepcache.go │ │ ├── prepcache_test.go │ │ ├── prepcountconfig.go │ │ ├── prepcountconfig_test.go │ │ ├── prepstatus.go │ │ ├── prepstatus_test.go │ │ ├── rewardcalcinfo.go │ │ ├── rewardcalcinfo_test.go │ │ ├── rewardfund.go │ │ ├── rewardfund_test.go │ │ ├── snapshot.go │ │ ├── state.go │ │ ├── state_test.go │ │ ├── term.go │ │ ├── term_test.go │ │ ├── timer.go │ │ ├── timer_test.go │ │ ├── timercache.go │ │ ├── timercache_test.go │ │ ├── unbond.go │ │ ├── unbond_test.go │ │ ├── unstake.go │ │ ├── unstake_test.go │ │ ├── validators.go │ │ ├── validators_test.go │ │ ├── voting.go │ │ └── voting_test.go │ ├── icutils │ │ ├── utils.go │ │ └── utils_test.go │ ├── issuer.go │ ├── issuer_test.go │ ├── module.go │ ├── penalty.go │ ├── statecontext.go │ └── timerhandler.go ├── lcimporter │ ├── blockconverter.go │ ├── blockconverter_test.go │ ├── chain.go │ ├── config.go │ ├── executor.go │ ├── executor_test.go │ ├── json.go │ ├── receipt.go │ ├── regulator.go │ ├── service.go │ ├── servicemanager.go │ ├── servicemanager_test.go │ ├── status.go │ ├── tpsmeasure.go │ ├── transaction.go │ └── transition.go ├── merkle │ ├── hexary │ │ ├── accumulator.go │ │ ├── accumulator_test.go │ │ ├── hexary_test.go │ │ ├── merkleheader.go │ │ ├── merkletree.go │ │ └── node.go │ └── merkle.go ├── platform.go ├── platform_test.go ├── revision.go ├── rlpstore.go ├── showextensiondiff.go ├── systemhandler.go └── transferhandler.go ├── iconee ├── README.md ├── VERSION ├── __init__.py ├── iconservice │ ├── __init__.py │ └── iconscore │ │ ├── __init__.py │ │ └── system.py ├── pyexec │ ├── __init__.py │ ├── __main__.py │ ├── base │ │ ├── __init__.py │ │ ├── address.py │ │ ├── block.py │ │ ├── exception.py │ │ ├── message.py │ │ ├── transaction.py │ │ ├── type_converter.py │ │ └── type_converter_templates.py │ ├── database │ │ ├── __init__.py │ │ ├── batch.py │ │ ├── db.py │ │ └── factory.py │ ├── icon_constant.py │ ├── iconscore │ │ ├── __init__.py │ │ ├── icon_container_db.py │ │ ├── icon_score_base.py │ │ ├── icon_score_base2.py │ │ ├── icon_score_constant.py │ │ ├── icon_score_context.py │ │ ├── icon_score_eventlog.py │ │ ├── icon_score_loader.py │ │ ├── icon_score_mapper.py │ │ ├── icon_score_step.py │ │ ├── icon_system_score_base.py │ │ ├── internal_call.py │ │ ├── score_api_generator.py │ │ ├── score_package_validator.py │ │ ├── system_score.py │ │ └── typing │ │ │ ├── __init__.py │ │ │ ├── definition.py │ │ │ └── element.py │ ├── ipc │ │ ├── __init__.py │ │ ├── client.py │ │ ├── proxy.py │ │ └── test_proxy.py │ ├── logger │ │ ├── __init__.py │ │ ├── logger.py │ │ └── utils.py │ ├── pyexec.py │ ├── service_engine.py │ └── utils │ │ ├── __init__.py │ │ └── bloom.py ├── requirements.txt └── setup.py ├── javaee ├── .gitignore ├── Makefile ├── README.md ├── api │ ├── build.gradle │ └── src │ │ └── java │ │ └── score │ │ ├── Address.java │ │ ├── ArrayDB.java │ │ ├── BranchDB.java │ │ ├── ByteArrayObjectWriter.java │ │ ├── Context.java │ │ ├── DictDB.java │ │ ├── ObjectReader.java │ │ ├── ObjectWriter.java │ │ ├── RevertedException.java │ │ ├── UserRevertException.java │ │ ├── UserRevertedException.java │ │ ├── VarDB.java │ │ └── annotation │ │ ├── EventLog.java │ │ ├── External.java │ │ ├── Keep.java │ │ ├── Optional.java │ │ └── Payable.java ├── app │ ├── allowlist │ │ ├── build.gradle │ │ └── src │ │ │ └── java │ │ │ └── JCLAllowlistPrinter.java │ ├── dappcomp │ │ ├── build.gradle │ │ └── src │ │ │ └── java │ │ │ └── DAppCompiler.java │ ├── execman │ │ ├── build.gradle │ │ └── src │ │ │ └── java │ │ │ └── Launcher.java │ └── proxytest │ │ ├── build.gradle │ │ └── src │ │ └── java │ │ └── ProxyTest.java ├── build.gradle ├── exec │ ├── build.gradle │ ├── src │ │ ├── java │ │ │ └── foundation │ │ │ │ └── icon │ │ │ │ └── ee │ │ │ │ ├── ipc │ │ │ │ ├── Client.java │ │ │ │ ├── Connection.java │ │ │ │ ├── Connector.java │ │ │ │ ├── EEProxy.java │ │ │ │ ├── ExecutorManager.java │ │ │ │ ├── InvokeResult.java │ │ │ │ ├── ManagerProxy.java │ │ │ │ ├── Proxy.java │ │ │ │ └── TypedObj.java │ │ │ │ └── score │ │ │ │ ├── ExternalState.java │ │ │ │ ├── FileIO.java │ │ │ │ └── TransactionExecutor.java │ │ └── native │ │ │ ├── Client.c │ │ │ ├── Makefile │ │ │ └── foundation_icon_ee_ipc_Client.h │ └── test │ │ ├── java │ │ └── foundation │ │ │ └── icon │ │ │ └── ee │ │ │ ├── BLSTest.java │ │ │ ├── CodecTest.java │ │ │ ├── CodecTest2.java │ │ │ ├── CodecTest3.java │ │ │ ├── CodecTest4.java │ │ │ ├── CompilerTest.java │ │ │ ├── DeployInvalidJarTest.java │ │ │ ├── DeployTest.java │ │ │ ├── DeployTest2.java │ │ │ ├── EnumCacheTest.java │ │ │ ├── EnumTest.java │ │ │ ├── EventTest.java │ │ │ ├── ExceptionTest.java │ │ │ ├── FeeSharingTest.java │ │ │ ├── IntercallRefTest.java │ │ │ ├── IntercallTest.java │ │ │ ├── IntercallTest2.java │ │ │ ├── JCFTest.java │ │ │ ├── KVDBStepTest.java │ │ │ ├── KVDBTest.java │ │ │ ├── LambdaExceptionTest.java │ │ │ ├── MapOrderTest.java │ │ │ ├── MapTest.java │ │ │ ├── ObjectHashTest.java │ │ │ ├── QueryTest.java │ │ │ ├── RLPTest.java │ │ │ ├── RangeTest.java │ │ │ ├── ReadOnlyTest.java │ │ │ ├── ReenterTest.java │ │ │ ├── RevertTest.java │ │ │ ├── SampleTest.java │ │ │ ├── ScenarioTest.java │ │ │ ├── SimpleCodecTest.java │ │ │ ├── StepTest.java │ │ │ ├── StructTest.java │ │ │ ├── TBCTest.java │ │ │ ├── ThrowableMessageTest.java │ │ │ ├── TypeTest.java │ │ │ ├── TypeTest2.java │ │ │ ├── UpdateTest.java │ │ │ ├── test │ │ │ ├── Account.java │ │ │ ├── Context.java │ │ │ ├── Contract.java │ │ │ ├── ContractAddress.java │ │ │ ├── Frame.java │ │ │ ├── GoldenTest.java │ │ │ ├── Indexer.java │ │ │ ├── InvokeHandler.java │ │ │ ├── Jars.java │ │ │ ├── Matcher.java │ │ │ ├── NoDebugTest.java │ │ │ ├── OriginFrame.java │ │ │ ├── Pipe.java │ │ │ ├── ServiceManager.java │ │ │ ├── SimpleTest.java │ │ │ ├── State.java │ │ │ ├── TeeOutputStream.java │ │ │ ├── TransactionException.java │ │ │ └── TxFrame.java │ │ │ └── tooling │ │ │ ├── BasicOptimizerTest.java │ │ │ ├── ClassRejectionTest.java │ │ │ ├── ExtendsTest.java │ │ │ ├── OptimizerGoldenTest.java │ │ │ ├── ScoreInheritanceTest.java │ │ │ └── StructOptimizerTest.java │ │ └── resources │ │ ├── foundation │ │ └── icon │ │ │ └── ee │ │ │ ├── StructTest-packagePrivateStruct.jar │ │ │ └── constant-dynamic.jar │ │ └── out │ │ └── foundation │ │ └── icon │ │ └── ee │ │ ├── CodecTest-test.txt │ │ ├── CompilerTest-testMultipleInits.txt │ │ ├── CompilerTest-testMultipleSameNames.txt │ │ ├── CompilerTest-testNoInit.txt │ │ ├── CompilerTest-testParamType.txt │ │ ├── CompilerTest-testReturnType.txt │ │ ├── EventTest-testLogEvents.txt │ │ ├── ExceptionTest-test.txt │ │ ├── FeeSharingTest-test.txt │ │ ├── IntercallRefTest-testRef1.txt │ │ ├── IntercallRefTest-testRef2.txt │ │ ├── IntercallRefTest-testRef3.txt │ │ ├── IntercallTest-testFail.txt │ │ ├── IntercallTest-testTypes.txt │ │ ├── JCFTest-test.txt │ │ ├── KVDBTest-testExampleScore.txt │ │ ├── QueryTest-testSetDB.txt │ │ ├── ReenterTest-test.txt │ │ ├── SampleTest-testIRC3.txt │ │ ├── SampleTest-testInherited.txt │ │ ├── SampleTest-testSample.txt │ │ ├── ScenarioTest-testBasic.txt │ │ ├── ScenarioTest-testDirectRecursion.txt │ │ ├── ScenarioTest-testDirectRecursion2.txt │ │ ├── ScenarioTest-testIndirectRecursion.txt │ │ ├── ScenarioTest-testIndirectRecursion2.txt │ │ ├── ScenarioTest-testIndirectRecursionWithMultiEE.txt │ │ ├── TypeTest-testTypes.txt │ │ └── tooling │ │ ├── BasicOptimizerTest-access.txt │ │ ├── BasicOptimizerTest-simple.txt │ │ ├── ExtendsTest-invokeSpecialParentMethodButImplementedInGrandparent.txt │ │ ├── StructOptimizerTest-paramCourse.txt │ │ ├── StructOptimizerTest-paramCourseF.txt │ │ ├── StructOptimizerTest-paramPerson.txt │ │ ├── StructOptimizerTest-paramPersonF.txt │ │ ├── StructOptimizerTest-paramStudent.txt │ │ ├── StructOptimizerTest-paramStudentF.txt │ │ ├── StructOptimizerTest-returnCourse.txt │ │ ├── StructOptimizerTest-returnCourseF.txt │ │ ├── StructOptimizerTest-returnPerson.txt │ │ ├── StructOptimizerTest-returnPersonF.txt │ │ ├── StructOptimizerTest-returnStudent.txt │ │ └── StructOptimizerTest-returnStudentF.txt ├── gradle.properties ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── logger │ ├── build.gradle │ └── src │ │ └── java │ │ ├── foundation │ │ └── icon │ │ │ └── ee │ │ │ └── logger │ │ │ ├── EELogger.java │ │ │ └── EELoggerFactory.java │ │ └── org │ │ └── slf4j │ │ └── impl │ │ └── StaticLoggerBinder.java ├── rt │ ├── build.gradle │ ├── src │ │ └── java │ │ │ ├── a │ │ │ ├── Array.java │ │ │ ├── ArrayElement.java │ │ │ ├── BooleanArray.java │ │ │ ├── ByteArray.java │ │ │ ├── CharArray.java │ │ │ ├── DoubleArray.java │ │ │ ├── FloatArray.java │ │ │ ├── IArray.java │ │ │ ├── IntArray.java │ │ │ ├── LongArray.java │ │ │ ├── ObjectArray.java │ │ │ └── ShortArray.java │ │ │ ├── e │ │ │ └── s │ │ │ │ └── java │ │ │ │ └── lang │ │ │ │ └── Throwable.java │ │ │ ├── foundation │ │ │ └── icon │ │ │ │ └── ee │ │ │ │ ├── Agent.java │ │ │ │ ├── io │ │ │ │ ├── AbstractRLPDataReader.java │ │ │ │ ├── AbstractRLPDataWriter.java │ │ │ │ ├── ByteArrayBuilder.java │ │ │ │ ├── DataReader.java │ │ │ │ ├── DataWriter.java │ │ │ │ ├── MessagePackDataReader.java │ │ │ │ ├── MessagePackDataWriter.java │ │ │ │ ├── RLPDataReader.java │ │ │ │ ├── RLPDataWriter.java │ │ │ │ ├── RLPNDataReader.java │ │ │ │ └── RLPNDataWriter.java │ │ │ │ ├── score │ │ │ │ ├── AvmExecutor.java │ │ │ │ ├── EEPType.java │ │ │ │ ├── Loader.java │ │ │ │ ├── ScoreClass.java │ │ │ │ ├── Transformer.java │ │ │ │ ├── ValidationException.java │ │ │ │ └── Validator.java │ │ │ │ ├── struct │ │ │ │ ├── ClassPropertyMemberInfo.java │ │ │ │ ├── ClassPropertyMemberInfoCollector.java │ │ │ │ ├── FieldProperty.java │ │ │ │ ├── Member.java │ │ │ │ ├── MemberDecl.java │ │ │ │ ├── MethodCollector.java │ │ │ │ ├── MethodProperty.java │ │ │ │ ├── Property.java │ │ │ │ ├── PropertyMember.java │ │ │ │ ├── ReadableMethodProperty.java │ │ │ │ ├── ReadableProperty.java │ │ │ │ ├── StructDB.java │ │ │ │ ├── WritableMethodProperty.java │ │ │ │ └── WritableProperty.java │ │ │ │ ├── types │ │ │ │ ├── Address.java │ │ │ │ ├── Bytes.java │ │ │ │ ├── DAppRuntimeState.java │ │ │ │ ├── IllegalFormatException.java │ │ │ │ ├── ManualRevertException.java │ │ │ │ ├── Method.java │ │ │ │ ├── ObjectGraph.java │ │ │ │ ├── PredefinedException.java │ │ │ │ ├── Result.java │ │ │ │ ├── Status.java │ │ │ │ ├── StepCost.java │ │ │ │ ├── Transaction.java │ │ │ │ └── UnknownFailureException.java │ │ │ │ └── util │ │ │ │ ├── ASM.java │ │ │ │ ├── Containers.java │ │ │ │ ├── Crypto.java │ │ │ │ ├── Disposable.java │ │ │ │ ├── DisposableReferenceQueue.java │ │ │ │ ├── IObjects.java │ │ │ │ ├── LinkedHashMultimap.java │ │ │ │ ├── LogMarker.java │ │ │ │ ├── MethodPacker.java │ │ │ │ ├── MethodUnpacker.java │ │ │ │ ├── Multimap.java │ │ │ │ ├── MultimapCache.java │ │ │ │ ├── Shadower.java │ │ │ │ ├── Strings.java │ │ │ │ ├── Unshadower.java │ │ │ │ ├── ValueCodec.java │ │ │ │ ├── bls12381 │ │ │ │ └── BLS12381.java │ │ │ │ └── xxhash │ │ │ │ ├── Access.java │ │ │ │ ├── LongHashFunction.java │ │ │ │ ├── UnsafeAccess.java │ │ │ │ └── XxHash.java │ │ │ ├── i │ │ │ ├── AvmError.java │ │ │ ├── AvmException.java │ │ │ ├── AvmThrowable.java │ │ │ ├── CodecIdioms.java │ │ │ ├── CommonInstrumentation.java │ │ │ ├── ConstantToken.java │ │ │ ├── ConstantsHolder.java │ │ │ ├── FrameContext.java │ │ │ ├── FunctionFactory.java │ │ │ ├── GenericPredefinedException.java │ │ │ ├── Helper.java │ │ │ ├── IBlockchainRuntime.java │ │ │ ├── IDBStorage.java │ │ │ ├── IInstrumentation.java │ │ │ ├── IInstrumentationFactory.java │ │ │ ├── IObject.java │ │ │ ├── IObjectArray.java │ │ │ ├── IObjectDeserializer.java │ │ │ ├── IObjectSerializer.java │ │ │ ├── IRuntimeSetup.java │ │ │ ├── InstrumentationHelpers.java │ │ │ ├── InternedClasses.java │ │ │ ├── InvokeDynamicChecks.java │ │ │ ├── JvmError.java │ │ │ ├── OutOfEnergyException.java │ │ │ ├── OutOfStackException.java │ │ │ ├── PackageConstants.java │ │ │ ├── RLPCoder.java │ │ │ ├── RunnableFactory.java │ │ │ ├── RuntimeAssertionError.java │ │ │ ├── ShadowClassConstantId.java │ │ │ ├── StackWatcher.java │ │ │ └── UncaughtException.java │ │ │ ├── org │ │ │ └── aion │ │ │ │ ├── avm │ │ │ │ ├── ArrayClassNameMapper.java │ │ │ │ ├── ArrayRenamer.java │ │ │ │ ├── ArrayUtil.java │ │ │ │ ├── ClassNameExtractor.java │ │ │ │ ├── EnergyCalculator.java │ │ │ │ ├── NameStyle.java │ │ │ │ ├── RuntimeMethodFeeSchedule.java │ │ │ │ ├── StorageFees.java │ │ │ │ ├── core │ │ │ │ │ ├── ArraySuperResolver.java │ │ │ │ │ ├── AvmConfiguration.java │ │ │ │ │ ├── BillingRules.java │ │ │ │ │ ├── BlockchainRuntimeImpl.java │ │ │ │ │ ├── ClassHierarchyForest.java │ │ │ │ │ ├── ClassRenamer.java │ │ │ │ │ ├── ClassRenamerBuilder.java │ │ │ │ │ ├── ClassToolchain.java │ │ │ │ │ ├── CommonAvmFactory.java │ │ │ │ │ ├── ConstantClassBuilder.java │ │ │ │ │ ├── DAppCreator.java │ │ │ │ │ ├── DAppExecutor.java │ │ │ │ │ ├── DAppLoader.java │ │ │ │ │ ├── DBStorage.java │ │ │ │ │ ├── ExceptionWrapperSuperResolver.java │ │ │ │ │ ├── FrameContextImpl.java │ │ │ │ │ ├── IExternalState.java │ │ │ │ │ ├── NodeEnvironment.java │ │ │ │ │ ├── PlainTypeSuperResolver.java │ │ │ │ │ ├── ReentrantDAppStack.java │ │ │ │ │ ├── TypeAwareClassWriter.java │ │ │ │ │ ├── arraywrapping │ │ │ │ │ │ ├── ArrayNameMapper.java │ │ │ │ │ │ ├── ArrayWrappingClassGenerator.java │ │ │ │ │ │ ├── ArrayWrappingInterpreter.java │ │ │ │ │ │ ├── ArraysRequiringAnalysisClassVisitor.java │ │ │ │ │ │ ├── ArraysRequiringAnalysisMethodNode.java │ │ │ │ │ │ ├── ArraysWithKnownTypesAdapter.java │ │ │ │ │ │ └── ArraysWithKnownTypesClassVisitor.java │ │ │ │ │ ├── classgeneration │ │ │ │ │ │ ├── CommonGenerators.java │ │ │ │ │ │ └── StubGenerator.java │ │ │ │ │ ├── classloading │ │ │ │ │ │ ├── AvmClassLoader.java │ │ │ │ │ │ └── AvmSharedClassLoader.java │ │ │ │ │ ├── dappreading │ │ │ │ │ │ └── LoadedJar.java │ │ │ │ │ ├── exceptionwrapping │ │ │ │ │ │ ├── ExceptionWrapperNameMapper.java │ │ │ │ │ │ └── ExceptionWrapping.java │ │ │ │ │ ├── instrument │ │ │ │ │ │ ├── BasicBlock.java │ │ │ │ │ │ ├── BlockBuildingMethodVisitor.java │ │ │ │ │ │ ├── BytecodeFeeScheduler.java │ │ │ │ │ │ ├── ChargeEnergyInjectionVisitor.java │ │ │ │ │ │ ├── ClassMetering.java │ │ │ │ │ │ ├── ClassRewriter.java │ │ │ │ │ │ ├── HeapMemoryCostCalculator.java │ │ │ │ │ │ └── JCLAndAPIHeapInstanceSize.java │ │ │ │ │ ├── miscvisitors │ │ │ │ │ │ ├── APIRemapClassVisitor.java │ │ │ │ │ │ ├── ClassRenameVisitor.java │ │ │ │ │ │ ├── ClinitStrippingVisitor.java │ │ │ │ │ │ ├── ConstantVisitor.java │ │ │ │ │ │ ├── InterfaceFieldClassGeneratorVisitor.java │ │ │ │ │ │ ├── InterfaceFieldNameMappingVisitor.java │ │ │ │ │ │ ├── LoopingExceptionStrippingVisitor.java │ │ │ │ │ │ ├── NamespaceMapper.java │ │ │ │ │ │ ├── PreRenameClassAccessRules.java │ │ │ │ │ │ ├── StrictFPVisitor.java │ │ │ │ │ │ ├── StringConstantCollectorVisitor.java │ │ │ │ │ │ └── UserClassMappingVisitor.java │ │ │ │ │ ├── persistence │ │ │ │ │ │ ├── AutomaticGraphVisitor.java │ │ │ │ │ │ ├── ByteBufferObjectDeserializer.java │ │ │ │ │ │ ├── ByteBufferObjectSerializer.java │ │ │ │ │ │ ├── ConstructorThisInterpreter.java │ │ │ │ │ │ ├── Deserializer.java │ │ │ │ │ │ ├── IGlobalResolver.java │ │ │ │ │ │ ├── IPersistenceNameMapper.java │ │ │ │ │ │ ├── LazyLoadingMethodVisitor.java │ │ │ │ │ │ ├── LoadedDApp.java │ │ │ │ │ │ ├── ReentrantGraph.java │ │ │ │ │ │ ├── ReferenceConstants.java │ │ │ │ │ │ ├── Serializer.java │ │ │ │ │ │ ├── SortedFieldCache.java │ │ │ │ │ │ ├── StackThisTracker.java │ │ │ │ │ │ ├── StandardGlobalResolver.java │ │ │ │ │ │ └── StandardNameMapper.java │ │ │ │ │ ├── rejection │ │ │ │ │ │ ├── ConsensusLimitConstants.java │ │ │ │ │ │ ├── InstanceVariableCountManager.java │ │ │ │ │ │ ├── InstanceVariableCountingVisitor.java │ │ │ │ │ │ ├── MainMethodChecker.java │ │ │ │ │ │ ├── RejectedClassException.java │ │ │ │ │ │ ├── RejectionAnnotationVisitor.java │ │ │ │ │ │ ├── RejectionClassVisitor.java │ │ │ │ │ │ ├── RejectionFieldVisitor.java │ │ │ │ │ │ └── RejectionMethodVisitor.java │ │ │ │ │ ├── shadowing │ │ │ │ │ │ ├── ClassShadowing.java │ │ │ │ │ │ ├── IObjectReplacer.java │ │ │ │ │ │ └── InvokedynamicShadower.java │ │ │ │ │ ├── stacktracking │ │ │ │ │ │ ├── StackWatcherClassAdapter.java │ │ │ │ │ │ └── StackWatcherMethodAdapter.java │ │ │ │ │ ├── types │ │ │ │ │ │ ├── ClassHierarchy.java │ │ │ │ │ │ ├── ClassHierarchyBuilder.java │ │ │ │ │ │ ├── ClassHierarchyVerifier.java │ │ │ │ │ │ ├── ClassInfo.java │ │ │ │ │ │ ├── ClassInfoVisitor.java │ │ │ │ │ │ ├── ClassInformation.java │ │ │ │ │ │ ├── ClassInformationFactory.java │ │ │ │ │ │ ├── ClassInformationRenamer.java │ │ │ │ │ │ ├── CommonType.java │ │ │ │ │ │ ├── DecoratedHierarchyNode.java │ │ │ │ │ │ ├── Forest.java │ │ │ │ │ │ ├── GeneratedClassConsumer.java │ │ │ │ │ │ ├── HierarchyGhostNode.java │ │ │ │ │ │ ├── HierarchyNode.java │ │ │ │ │ │ ├── HierarchyVerificationResult.java │ │ │ │ │ │ ├── IHierarchyNode.java │ │ │ │ │ │ ├── ImmortalDappModule.java │ │ │ │ │ │ ├── Pair.java │ │ │ │ │ │ ├── RawDappModule.java │ │ │ │ │ │ └── TransformedDappModule.java │ │ │ │ │ ├── util │ │ │ │ │ │ ├── AllowlistProvider.java │ │ │ │ │ │ ├── ByteArrayWrapper.java │ │ │ │ │ │ ├── DebugNameResolver.java │ │ │ │ │ │ ├── DescriptorParser.java │ │ │ │ │ │ ├── Helpers.java │ │ │ │ │ │ └── MethodDescriptorCollector.java │ │ │ │ │ └── verification │ │ │ │ │ │ ├── Verifier.java │ │ │ │ │ │ └── VerifierClassLoader.java │ │ │ │ └── utilities │ │ │ │ │ ├── JarBuilder.java │ │ │ │ │ ├── Utilities.java │ │ │ │ │ └── analyze │ │ │ │ │ ├── ByteReader.java │ │ │ │ │ ├── ClassFileInfoBuilder.java │ │ │ │ │ └── ConstantType.java │ │ │ │ └── parallel │ │ │ │ └── TransactionTask.java │ │ │ ├── p │ │ │ └── score │ │ │ │ ├── Address.java │ │ │ │ ├── AnyDB.java │ │ │ │ ├── ArrayDB.java │ │ │ │ ├── BranchDB.java │ │ │ │ ├── ByteArrayObjectWriter.java │ │ │ │ ├── Context.java │ │ │ │ ├── DictDB.java │ │ │ │ ├── InternalFunction.java │ │ │ │ ├── InternalRunnable.java │ │ │ │ ├── ObjectReader.java │ │ │ │ ├── ObjectWriter.java │ │ │ │ └── VarDB.java │ │ │ ├── pi │ │ │ ├── AnyDBImpl.java │ │ │ ├── ObjectReaderImpl.java │ │ │ ├── ObjectWriterImpl.java │ │ │ ├── UnmodifiableArrayCollection.java │ │ │ ├── UnmodifiableArrayContainer.java │ │ │ ├── UnmodifiableArrayList.java │ │ │ ├── UnmodifiableArrayMap.java │ │ │ ├── UnmodifiableArraySet.java │ │ │ └── UnmodifiableMapEntry.java │ │ │ └── s │ │ │ ├── java │ │ │ ├── io │ │ │ │ └── Serializable.java │ │ │ ├── lang │ │ │ │ ├── Appendable.java │ │ │ │ ├── AssertionError.java │ │ │ │ ├── Boolean.java │ │ │ │ ├── Byte.java │ │ │ │ ├── CharSequence.java │ │ │ │ ├── Character.java │ │ │ │ ├── Class.java │ │ │ │ ├── Cloneable.java │ │ │ │ ├── Comparable.java │ │ │ │ ├── Double.java │ │ │ │ ├── Enum.java │ │ │ │ ├── EnumConstantNotPresentException.java │ │ │ │ ├── Error.java │ │ │ │ ├── Exception.java │ │ │ │ ├── Float.java │ │ │ │ ├── Integer.java │ │ │ │ ├── Iterable.java │ │ │ │ ├── Long.java │ │ │ │ ├── Math.java │ │ │ │ ├── Number.java │ │ │ │ ├── Object.java │ │ │ │ ├── Runnable.java │ │ │ │ ├── RuntimeException.java │ │ │ │ ├── Short.java │ │ │ │ ├── StrictMath.java │ │ │ │ ├── String.java │ │ │ │ ├── StringBuffer.java │ │ │ │ ├── StringBuilder.java │ │ │ │ ├── System.java │ │ │ │ ├── Throwable.java │ │ │ │ ├── TypeNotPresentException.java │ │ │ │ ├── Void.java │ │ │ │ └── invoke │ │ │ │ │ ├── LambdaMetafactory.java │ │ │ │ │ └── StringConcatFactory.java │ │ │ ├── math │ │ │ │ ├── BigDecimal.java │ │ │ │ ├── BigInteger.java │ │ │ │ ├── MathContext.java │ │ │ │ └── RoundingMode.java │ │ │ └── util │ │ │ │ ├── Arrays.java │ │ │ │ ├── Collection.java │ │ │ │ ├── Iterator.java │ │ │ │ ├── List.java │ │ │ │ ├── ListIterator.java │ │ │ │ ├── Map.java │ │ │ │ ├── NoSuchElementException.java │ │ │ │ ├── Set.java │ │ │ │ ├── concurrent │ │ │ │ └── TimeUnit.java │ │ │ │ └── function │ │ │ │ └── Function.java │ │ │ └── score │ │ │ ├── RevertedException.java │ │ │ ├── UserRevertException.java │ │ │ └── UserRevertedException.java │ └── test │ │ └── java │ │ ├── foundation │ │ └── icon │ │ │ └── ee │ │ │ ├── io │ │ │ ├── ObjectIOForRLPTest.java │ │ │ ├── RLPCodecTest.java │ │ │ ├── RLPDataReaderWriterTest.java │ │ │ ├── RLPNCodecTest.java │ │ │ └── RLPObjectReaderWriterTest.java │ │ │ ├── test │ │ │ ├── TBCProtocol.java │ │ │ ├── TBCTestScenario.java │ │ │ └── TBCTestScenarios.java │ │ │ └── util │ │ │ ├── BLSTest.java │ │ │ ├── HashTest.java │ │ │ ├── LinkedHashMultimapTest.java │ │ │ └── MultimapCacheTest.java │ │ ├── i │ │ └── RLPCoderTest.java │ │ ├── org │ │ └── aion │ │ │ └── avm │ │ │ └── core │ │ │ └── persistence │ │ │ ├── SerializerTest.java │ │ │ ├── TargetArray.java │ │ │ ├── TargetIntArray.java │ │ │ ├── TargetLeaf.java │ │ │ ├── TargetRoot.java │ │ │ ├── TargetStatics.java │ │ │ └── TestObjectSerializer.java │ │ ├── pi │ │ └── UnmodifiableArrayMapTest.java │ │ └── testutils │ │ └── TestInstrumentation.java ├── samples │ ├── build.gradle │ ├── collection │ │ └── src │ │ │ └── collection │ │ │ └── CollectionTest.java │ ├── compile.sh │ ├── crowdsale │ │ └── src │ │ │ └── example │ │ │ └── SampleCrowdsale.java │ ├── governance │ │ └── src │ │ │ └── governance │ │ │ ├── Governance.java │ │ │ └── SystemInterface.java │ ├── multisig │ │ └── src │ │ │ └── example │ │ │ ├── MultiSigWallet.java │ │ │ ├── StringTokenizer.java │ │ │ └── Transaction.java │ ├── sampletoken │ │ └── src │ │ │ └── example │ │ │ ├── IRC2BasicToken.java │ │ │ ├── IRC3BasicToken.java │ │ │ ├── SampleToken.java │ │ │ ├── token │ │ │ ├── IRC2.java │ │ │ ├── IRC2Basic.java │ │ │ ├── IRC2Burnable.java │ │ │ ├── IRC3.java │ │ │ └── IRC3Basic.java │ │ │ └── util │ │ │ ├── EnumerableIntMap.java │ │ │ ├── EnumerableSet.java │ │ │ └── IntSet.java │ ├── tbcinterpreter │ │ └── src │ │ │ └── test │ │ │ ├── TBCInterpreter.java │ │ │ └── TBCProtocol.java │ └── testcases │ │ └── src │ │ └── testcases │ │ ├── APITest.java │ │ ├── BLSTestScore.java │ │ ├── BTP2.java │ │ ├── BTP2BMC.java │ │ ├── ContainerDB.java │ │ ├── DeployScore.java │ │ ├── EventGen.java │ │ ├── FeeSharing.java │ │ ├── HelloWorld.java │ │ └── StructHolder.java ├── settings.gradle └── tooling │ ├── build.gradle │ └── src │ └── java │ ├── foundation │ └── icon │ │ └── ee │ │ └── tooling │ │ ├── abi │ │ ├── ABICompiler.java │ │ ├── ABICompilerClassVisitor.java │ │ ├── ABICompilerException.java │ │ ├── ABICompilerFieldVisitor.java │ │ ├── ABICompilerMethodVisitor.java │ │ └── KeptMemberCollector.java │ │ └── deploy │ │ └── OptimizedJarBuilder.java │ └── org │ └── aion │ └── avm │ └── tooling │ └── deploy │ ├── ClassDependencyVisitor.java │ ├── DependencyCollector.java │ ├── JarOptimizer.java │ ├── MethodDependencyVisitor.java │ ├── SignatureDependencyVisitor.java │ ├── eliminator │ ├── AllowlistPopulator.java │ ├── ClassDependencyVisitor.java │ ├── ClassInfo.java │ ├── ClassUnreachabilityVisitor.java │ ├── JarDependencyCollector.java │ ├── MethodDependencyVisitor.java │ ├── MethodInfo.java │ ├── MethodInvocation.java │ ├── MethodReachabilityDetector.java │ ├── ParameterNameRemover.java │ └── UnreachableMethodRemover.java │ └── renamer │ ├── ClassRenamer.java │ ├── FieldRenamer.java │ ├── MethodRenamer.java │ ├── NameGenerator.java │ └── Renamer.java ├── module ├── bitsetfilter.go ├── bitsetfilter_test.go ├── block.go ├── btp.go ├── chain.go ├── common.go ├── consensus.go ├── doublesign.go ├── locator.go ├── network.go ├── patch.go ├── revision.go ├── service.go └── trace.go ├── network ├── authenticator.go ├── authenticator_test.go ├── channelnegotiator.go ├── channelnegotiator_test.go ├── error.go ├── inspect.go ├── network.go ├── network_test.go ├── p2p.go ├── p2p_test.go ├── packet.go ├── packet_test.go ├── peer.go ├── peer_test.go ├── peerdispatcher.go ├── peerdispatcher_test.go ├── peerhandler.go ├── peerhandler_test.go ├── peerid.go ├── pool.go ├── pool_test.go ├── protocolhandler.go ├── protocolinfos.go ├── protocolinfos_test.go ├── queue.go ├── queue_test.go ├── secure.go ├── set.go ├── set_test.go ├── stream.go ├── stream_test.go ├── transport.go └── transport_test.go ├── node ├── auth.go ├── config.go ├── node.go ├── rest.go ├── restore.go └── unixhttp.go ├── pyee ├── README.md ├── VERSION ├── iconservice │ └── __init__.py ├── pyexec │ ├── __init__.py │ ├── __main__.py │ ├── base │ │ ├── __init__.py │ │ ├── address.py │ │ ├── block.py │ │ ├── exception.py │ │ ├── message.py │ │ ├── transaction.py │ │ ├── type_converter.py │ │ └── type_converter_templates.py │ ├── database │ │ ├── __init__.py │ │ ├── batch.py │ │ ├── db.py │ │ └── factory.py │ ├── icon_constant.py │ ├── iconscore │ │ ├── __init__.py │ │ ├── icon_container_db.py │ │ ├── icon_score_base.py │ │ ├── icon_score_base2.py │ │ ├── icon_score_constant.py │ │ ├── icon_score_context.py │ │ ├── icon_score_eventlog.py │ │ ├── icon_score_loader.py │ │ ├── icon_score_mapper.py │ │ ├── icon_score_step.py │ │ ├── internal_call.py │ │ ├── score_api_generator.py │ │ ├── score_package_validator.py │ │ └── typing │ │ │ ├── __init__.py │ │ │ ├── definition.py │ │ │ └── element.py │ ├── ipc │ │ ├── __init__.py │ │ ├── client.py │ │ ├── proxy.py │ │ └── test_proxy.py │ ├── logger │ │ ├── __init__.py │ │ ├── logger.py │ │ └── utils.py │ ├── pyexec.py │ ├── service_engine.py │ └── utils │ │ ├── __init__.py │ │ └── bloom.py ├── requirements.txt ├── setup.py └── tests │ ├── __init__.py │ ├── test_container_db.py │ ├── test_icon_score_api.py │ └── test_step_counter.py ├── sdk └── java │ ├── build.gradle │ ├── gradle.properties │ ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties │ ├── gradlew │ ├── gradlew.bat │ ├── library │ ├── build.gradle │ └── src │ │ └── main │ │ └── java │ │ └── foundation │ │ └── icon │ │ └── icx │ │ ├── Call.java │ │ ├── Callback.java │ │ ├── IconService.java │ │ ├── KeyWallet.java │ │ ├── Provider.java │ │ ├── Request.java │ │ ├── SignedTransaction.java │ │ ├── Transaction.java │ │ ├── TransactionBuilder.java │ │ ├── Wallet.java │ │ ├── crypto │ │ ├── ECDSASignature.java │ │ ├── IconKeys.java │ │ ├── KeyStoreUtils.java │ │ ├── Keystore.java │ │ ├── KeystoreException.java │ │ ├── KeystoreFile.java │ │ └── LinuxSecureRandom.java │ │ ├── data │ │ ├── Address.java │ │ ├── BTPNetworkInfo.java │ │ ├── BTPNetworkTypeInfo.java │ │ ├── BTPNotification.java │ │ ├── BTPSourceInfo.java │ │ ├── Base64.java │ │ ├── Block.java │ │ ├── BlockNotification.java │ │ ├── Bytes.java │ │ ├── ConfirmedTransaction.java │ │ ├── Converters.java │ │ ├── EventNotification.java │ │ ├── IconAmount.java │ │ ├── NetworkId.java │ │ ├── NetworkInfo.java │ │ ├── ScoreApi.java │ │ ├── ScoreStatus.java │ │ └── TransactionResult.java │ │ └── transport │ │ ├── http │ │ ├── HttpCall.java │ │ └── HttpProvider.java │ │ ├── jsonrpc │ │ ├── AnnotatedConverterFactory.java │ │ ├── AnnotationConverter.java │ │ ├── ConverterName.java │ │ ├── Request.java │ │ ├── Response.java │ │ ├── RpcArray.java │ │ ├── RpcConverter.java │ │ ├── RpcError.java │ │ ├── RpcItem.java │ │ ├── RpcItemCreator.java │ │ ├── RpcItemDeserializer.java │ │ ├── RpcItemSerializer.java │ │ ├── RpcObject.java │ │ └── RpcValue.java │ │ └── monitor │ │ ├── BTPMonitorSpec.java │ │ ├── BlockMonitorSpec.java │ │ ├── EventMonitorSpec.java │ │ ├── Monitor.java │ │ └── MonitorSpec.java │ ├── publish.gradle │ └── settings.gradle ├── server ├── error.go ├── jsonrpc │ ├── error.go │ ├── error_test.go │ ├── jsonrpc.go │ ├── method.go │ ├── method_test.go │ ├── type.go │ ├── type_test.go │ ├── validator.go │ └── validator_test.go ├── metric │ ├── consensus.go │ ├── jsonrpc.go │ ├── metric.go │ ├── network.go │ └── transaction.go ├── middleware.go ├── redoc.go ├── server.go ├── v3 │ ├── api_v3.go │ ├── missingtxinfo.go │ ├── missingtxinfo_test.go │ ├── schema_v3.go │ ├── tracecallback.go │ ├── validation.go │ └── validation_test.go ├── websocket.go ├── websocket_test.go ├── wsblock.go ├── wsblock_test.go ├── wsbtp.go ├── wsevent.go └── wsevent_test.go ├── service ├── contract │ ├── callcontext.go │ ├── callcontext_test.go │ ├── callframe.go │ ├── callhandler.go │ ├── context.go │ ├── contracthandler.go │ ├── contractmanager.go │ ├── customlogs.go │ ├── deployhandler.go │ ├── deposithandler.go │ ├── dscontext.go │ ├── dscontext_test.go │ ├── dsrhandler.go │ ├── dsrhandler_test.go │ ├── errors.go │ ├── feepayerinfo.go │ ├── feepayerinfo_test.go │ ├── helper.go │ ├── helper_test.go │ ├── patchhandler.go │ ├── systemscore.go │ ├── systemscore_test.go │ └── transferhandler.go ├── databaseadaptor.go ├── dsrmanager.go ├── dsrmanager_test.go ├── eeproxy │ ├── enginefactory.go │ ├── executorconnection.go │ ├── javaee.go │ ├── manager.go │ ├── managerproxy.go │ ├── proxy.go │ └── pyee.go ├── error.go ├── executionresult.go ├── inspect.go ├── manager.go ├── memberlist.go ├── platform │ └── basic │ │ ├── chainscore.go │ │ ├── chainscore_test.go │ │ ├── platform.go │ │ └── revision.go ├── queryhandler.go ├── scoreapi │ ├── error.go │ ├── info.go │ ├── info_test.go │ ├── method.go │ └── method_test.go ├── scoredb │ └── scoredb.go ├── scoreresult │ └── errors.go ├── showresultdiff.go ├── state │ ├── account.go │ ├── account_test.go │ ├── apiinfo.go │ ├── apiinfocache.go │ ├── apiinfocache_test.go │ ├── btp.go │ ├── common.go │ ├── contract.go │ ├── deposit.go │ ├── depositlist.go │ ├── depositlist_test.go │ ├── dsrcontext.go │ ├── dsrcontext_test.go │ ├── eetype.go │ ├── extension.go │ ├── objectgraph.go │ ├── readonlyworldstate.go │ ├── validator.go │ ├── validator_test.go │ ├── validatorlist.go │ ├── validatorlist_test.go │ ├── worldcontext.go │ ├── worldcontext_icon.go │ ├── worldstate.go │ ├── worldstate_test.go │ ├── worldvirtualstate.go │ └── worldvirtualstate_test.go ├── sync │ ├── client.go │ ├── datasyncer.go │ ├── manager.go │ ├── peer.go │ ├── protocol.go │ ├── server.go │ ├── sync_test.go │ └── syncer.go ├── sync2 │ ├── datasyncer.go │ ├── manager.go │ ├── peer.go │ ├── peerpool.go │ ├── peerpool_test.go │ ├── progress.go │ ├── protocol.go │ ├── protocolv2.go │ ├── reactor.go │ ├── reactor_test.go │ ├── reactorv2.go │ ├── sync_test.go │ ├── syncer.go │ ├── syncprocessor.go │ └── syncprocessor_test.go ├── trace │ ├── balancetracer.go │ ├── balancetracer_test.go │ ├── logger.go │ ├── traceblock.go │ └── util.go ├── transaction │ ├── doublesignreport.go │ ├── doublesignreport_test.go │ ├── errors.go │ ├── factory.go │ ├── factory_test.go │ ├── genesis_v3.go │ ├── genesis_v3_test.go │ ├── patchtransaction.go │ ├── serialize.go │ ├── transaction.go │ ├── transaction_json.go │ ├── transaction_v2.go │ ├── transaction_v3.go │ ├── transactionhandler.go │ ├── transactionlist.go │ ├── transactionlist_test.go │ ├── transactionlist_v1.go │ └── wrapper.go ├── transactionlist.go ├── transactionlist_test.go ├── transactionmanager.go ├── transactionpool.go ├── transactionpool_test.go ├── transactionreactor.go ├── transition.go ├── transition_pe.go ├── transition_se.go ├── transition_test.go ├── transitionresult.go ├── transitionresult_test.go ├── transitionresultcache.go ├── transitionresultcache_test.go ├── tschecker.go ├── txidcache.go ├── txidcache_test.go ├── txidmanager.go ├── txidmanager_test.go ├── txresult │ ├── feedetail.go │ ├── feedetail_test.go │ ├── logsbloom.go │ ├── logsbloom_test.go │ ├── receipt.go │ ├── receipt_icon.go │ ├── receipt_test.go │ ├── receiptlist.go │ ├── receiptlist_test.go │ └── testeventlog.go ├── txshare.go └── txshare_test.go ├── test ├── blockmanager.go ├── chain.go ├── clock │ └── clock.go ├── debug.go ├── fixture.go ├── fixtureconfig.go ├── fixtureoption.go ├── networkmanager.go ├── node.go ├── peer.go ├── regulator.go ├── rlp_test.go ├── servicemanager.go ├── simplepeer.go └── transaction.go └── testsuite ├── README.md ├── build.gradle ├── data ├── chainenv │ ├── java.props │ ├── javagov.props │ ├── py.props │ └── pygov.props ├── config │ ├── java.json │ ├── javagov.json │ ├── py.json │ └── pygov.json ├── dockerenv │ ├── javagov │ ├── javascore │ ├── pyaudit │ ├── pygov │ └── pyscore ├── genesisStorage │ ├── genesis_audit.json │ ├── genesis_gov.json │ ├── genesis_java.json │ ├── genesis_javagov.json │ ├── genesis_py.json │ ├── governance-optimized.jar │ └── governance │ │ ├── __init__.py │ │ ├── governance.py │ │ └── package.json ├── keystore_god.json ├── keystore_gov.json ├── resource │ └── invalidJars │ │ └── Case1.jar └── scores │ ├── check_params │ ├── __init__.py │ ├── check_params.py │ └── package.json │ ├── container_db │ ├── __init__.py │ ├── container_db.py │ └── package.json │ ├── db_step │ ├── __init__.py │ ├── db_step.py │ └── package.json │ ├── event_gen │ ├── __init__.py │ ├── event_gen.py │ └── package.json │ ├── fee_sharing │ ├── __init__.py │ ├── fee_sharing.py │ └── package.json │ ├── governance │ ├── __init__.py │ ├── governance.py │ └── package.json │ ├── hello_world │ ├── __init__.py │ ├── hello_world.py │ └── package.json │ ├── hello_world2 │ ├── __init__.py │ ├── hello_world.py │ └── package.json │ ├── method_caller │ ├── __init__.py │ ├── method_caller.py │ └── package.json │ ├── multisig_wallet │ ├── __init__.py │ ├── multisig_wallet.py │ ├── package.json │ ├── qualification_check │ │ ├── __init__.py │ │ └── qualification_check.py │ ├── transaction.py │ └── type_converter │ │ ├── __init__.py │ │ └── type_converter.py │ ├── no_install_method │ ├── __init__.py │ ├── no_install_method.py │ └── package.json │ ├── no_update_method │ ├── __init__.py │ ├── no_update_method.py │ └── package.json │ ├── receipt │ ├── __init__.py │ ├── package.json │ └── receipt.py │ ├── result_gen │ ├── __init__.py │ ├── package.json │ └── result_gen.py │ ├── sample_crowdsale │ ├── __init__.py │ ├── package.json │ └── sample_crowdsale.py │ ├── sample_token │ ├── __init__.py │ ├── package.json │ └── sample_token.py │ ├── score_api │ ├── __init__.py │ ├── package.json │ └── score_api.py │ ├── step_counter │ ├── __init__.py │ ├── package.json │ └── step_counter.py │ ├── tbc_interpreter │ ├── __init__.py │ ├── package.json │ └── tbc_interpreter.py │ └── too_big │ ├── __init__.py │ ├── month_1.jpg │ ├── month_2.jpg │ ├── package.json │ └── too_big.py ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── java └── foundation │ └── icon │ └── test │ ├── cases │ ├── BTP2APITest.java │ ├── BtpApiTest.java │ ├── ChainScoreTest.java │ ├── ContainerTest.java │ ├── CrowdsaleTest.java │ ├── DeployTest.java │ ├── FeeSharingTest.java │ ├── GetAPITest.java │ ├── GetStatusTest.java │ ├── GetTotalSupplyTest.java │ ├── InvokeTest.java │ ├── InvokeTestStep.java │ ├── JavaAPITest.java │ ├── JavaTokenTest.java │ ├── MultiSigWalletTest.java │ ├── NetworkInfoTest.java │ ├── NodeWalletTest.java │ ├── ReceiptTest.java │ ├── ResultTest.java │ ├── RevertTest.java │ ├── ScoreEventTest.java │ ├── ScoreMethodTest.java │ ├── ScoreParamTest.java │ ├── SendAndWaitTest.java │ ├── StepTest.java │ ├── StructHolderTest.java │ ├── TBCTest.java │ ├── TransferTest.java │ └── WSEventTest.java │ ├── common │ ├── BTPBlockHeader.java │ ├── BlockHeader.java │ ├── Codec.java │ ├── Constants.java │ ├── Env.java │ ├── EventLog.java │ ├── Log.java │ ├── NotEnoughBalanceException.java │ ├── ResultTimeoutException.java │ ├── RpcItems.java │ ├── TestBase.java │ ├── TransactionFailureException.java │ ├── TransactionHandler.java │ ├── ValidatorList.java │ ├── Votes.java │ └── ZipFile.java │ └── score │ ├── BTP2.java │ ├── ChainScore.java │ ├── ContainerScore.java │ ├── CrowdSaleScore.java │ ├── EventGen.java │ ├── FeeShareScore.java │ ├── GovScore.java │ ├── HelloWorld.java │ ├── IRC3TokenScore.java │ ├── MultiSigWalletScore.java │ ├── SampleTokenScore.java │ ├── Score.java │ ├── StepCounterScore.java │ ├── StructHolderScore.java │ └── TBCInterpreterScore.java └── settings.gradle /.github/workflows/coverage.yml: -------------------------------------------------------------------------------- 1 | name: Code Coverage with Codecov 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | pull_request: 8 | branches: 9 | - master 10 | jobs: 11 | Coverage: 12 | runs-on: ubuntu-latest 13 | steps: 14 | - name: Checkout repository 15 | uses: actions/checkout@v3 16 | 17 | - name: Setup Go 18 | uses: actions/setup-go@v3 19 | with: 20 | go-version: '1.20.10' 21 | 22 | - name: GO test 23 | run: | 24 | go test ./... -short -timeout=3m -covermode=atomic -coverprofile=coverage.out 25 | 26 | - name: Upload coverage to Codecov 27 | uses: codecov/codecov-action@v3 28 | -------------------------------------------------------------------------------- /.github/workflows/go_test.yml: -------------------------------------------------------------------------------- 1 | name: Go test 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | pull_request: 8 | branches: 9 | - master 10 | 11 | jobs: 12 | build: 13 | runs-on: ubuntu-latest 14 | steps: 15 | - uses: actions/checkout@v3 16 | 17 | - name: Set up Go 18 | uses: actions/setup-go@v3 19 | with: 20 | go-version: '1.20.10' 21 | 22 | - name: Build 23 | run: GOBUILD_TAGS= make 24 | 25 | - name: Test 26 | run: GOBUILD_TAGS= make test 27 | 28 | - name: Test Race 29 | run: GOBUILD_TAGS= make test-race 30 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .?* 2 | !.github 3 | !doc/.vuepress 4 | __pycache__ 5 | **/.DS_Store 6 | **/*.iml 7 | doc.tmp/ 8 | build/ 9 | bin/ 10 | -------------------------------------------------------------------------------- /block/blockcandidate.go: -------------------------------------------------------------------------------- 1 | package block 2 | 3 | import ( 4 | "github.com/icon-project/goloop/chain/base" 5 | "github.com/icon-project/goloop/module" 6 | ) 7 | 8 | type blockCandidate struct { 9 | base.Block 10 | m *manager 11 | } 12 | 13 | func (bc *blockCandidate) Dispose() { 14 | if bc != nil { 15 | bc.m.DisposeBlockCandidate(bc) 16 | } 17 | } 18 | 19 | func (bc *blockCandidate) Dup() module.BlockCandidate { 20 | return bc.m.DupBlockCandidate(bc) 21 | } 22 | -------------------------------------------------------------------------------- /block/errors.go: -------------------------------------------------------------------------------- 1 | package block 2 | 3 | import "github.com/icon-project/goloop/common/errors" 4 | 5 | const ( 6 | ResultNotFinalizedError = errors.CodeBlock + iota 7 | ) 8 | 9 | var ( 10 | ErrResultNotFinalized = errors.NewBase(ResultNotFinalizedError, "ResultNotFinalized") 11 | ) 12 | -------------------------------------------------------------------------------- /block/syncer.go: -------------------------------------------------------------------------------- 1 | package block 2 | 3 | import "sync" 4 | 5 | type syncer struct { 6 | mutex sync.Mutex 7 | lcbs []func() 8 | cbs []func() 9 | } 10 | 11 | func (s *syncer) begin() { 12 | s.mutex.Lock() 13 | } 14 | 15 | func (s *syncer) callLater(cb func()) { 16 | s.cbs = append(s.cbs, cb) 17 | } 18 | 19 | func (s *syncer) callLaterInLock(cb func()) { 20 | s.lcbs = append(s.lcbs, cb) 21 | } 22 | 23 | func (s *syncer) end() { 24 | for s.lcbs != nil { 25 | lcbs := s.lcbs 26 | s.lcbs = nil 27 | for _, cb := range lcbs { 28 | cb() 29 | } 30 | } 31 | cbs := s.cbs 32 | s.cbs = nil 33 | s.mutex.Unlock() 34 | for _, cb := range cbs { 35 | cb() 36 | } 37 | } 38 | 39 | func (s *syncer) Lock() { 40 | s.begin() 41 | } 42 | 43 | func (s *syncer) Unlock() { 44 | s.end() 45 | } 46 | -------------------------------------------------------------------------------- /btp/digestfrombytes_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 ICON Foundation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package btp 18 | 19 | import "testing" 20 | 21 | func FuzzNewDigestFromBytes(f *testing.F) { 22 | cases := [][]byte{ 23 | []byte("\xd7\xcdk>y\x11\xf9("), 24 | } 25 | for _, c := range cases { 26 | f.Add(c) 27 | } 28 | f.Fuzz(func(t *testing.T, bs []byte) { 29 | _, _ = NewDigestFromBytes(bs) 30 | }) 31 | } 32 | -------------------------------------------------------------------------------- /btp/ntm/dsam.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 ICON Foundation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package ntm 18 | 19 | import "github.com/icon-project/goloop/module" 20 | 21 | var dsaModules = make(map[string]module.DSAModule) 22 | 23 | func DSAModuleForName(name string) module.DSAModule { 24 | return dsaModules[name] 25 | } 26 | 27 | func registerDSAModule(dsa module.DSAModule) { 28 | dsaModules[dsa.Name()] = dsa 29 | } 30 | -------------------------------------------------------------------------------- /cmd/gochain/icon.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 ICON Foundation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package main 18 | 19 | import ( 20 | "github.com/icon-project/goloop/chain" 21 | "github.com/icon-project/goloop/icon" 22 | ) 23 | 24 | func init() { 25 | chain.RegisterPlatform("icon", icon.NewPlatform) 26 | } 27 | -------------------------------------------------------------------------------- /cmd/goloop/icon.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 ICON Foundation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package main 18 | 19 | import ( 20 | "github.com/icon-project/goloop/chain" 21 | "github.com/icon-project/goloop/icon" 22 | ) 23 | 24 | func init() { 25 | chain.RegisterPlatform("icon", icon.NewPlatform) 26 | } 27 | -------------------------------------------------------------------------------- /cmd/gstool/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "os" 5 | 6 | "github.com/icon-project/goloop/cmd/cli" 7 | "github.com/spf13/cobra" 8 | ) 9 | 10 | func main() { 11 | cmd := &cobra.Command{Use: os.Args[0]} 12 | cmd.AddCommand(cli.NewGStorageCmd("gs")) 13 | cmd.AddCommand(cli.NewGenesisCmd("gn")) 14 | cmd.AddCommand(cli.NewKeystoreCmd("ks")) 15 | cmd.Execute() 16 | } 17 | -------------------------------------------------------------------------------- /cmd/txgen/txpool.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 ICON Foundation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | 18 | package main 19 | 20 | import ( 21 | v3 "github.com/icon-project/goloop/server/v3" 22 | "sync" 23 | ) 24 | 25 | type TxPool struct { 26 | Pool sync.Pool 27 | Base v3.TransactionParam 28 | } 29 | 30 | func (p *TxPool) Init() { 31 | p.Pool.New = func() interface{} { 32 | var tx = p.Base 33 | return &tx 34 | } 35 | } 36 | 37 | func (p *TxPool) Get() *v3.TransactionParam { 38 | return p.Pool.Get().(*v3.TransactionParam) 39 | } 40 | 41 | func (p *TxPool) Put(tx interface{}) { 42 | p.Pool.Put(tx) 43 | } 44 | -------------------------------------------------------------------------------- /codecov.yml: -------------------------------------------------------------------------------- 1 | codecov: 2 | require_ci_to_pass: true 3 | 4 | comment: 5 | behavior: default 6 | layout: "reach, diff, flags, files" 7 | 8 | ignore: 9 | - "**/test_*" 10 | - "**/*_test.*" 11 | - "**/mocks/*" 12 | - "**/mock/*" 13 | - "module" 14 | - "test" 15 | 16 | coverage: 17 | precision: 2 18 | range: 50..80 19 | round: down 20 | status: 21 | project: no 22 | patch: 23 | default: 24 | target: auto 25 | threshold: 3% 26 | base: auto 27 | changes: no 28 | 29 | github_checks: 30 | annotations: false 31 | -------------------------------------------------------------------------------- /common/cache/byteslice.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 ICON Foundation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package cache 18 | 19 | var pseudoNil = []byte{0} 20 | 21 | type ByteSlice struct { 22 | val []byte 23 | } 24 | 25 | func (s ByteSlice) Get(fn func() []byte) []byte { 26 | if s.val == nil { 27 | s.val = fn() 28 | if s.val == nil { 29 | s.val = pseudoNil 30 | } 31 | } 32 | if len(s.val) == 1 && &s.val[0] == &pseudoNil[0] { 33 | return nil 34 | } 35 | return s.val 36 | } 37 | -------------------------------------------------------------------------------- /common/clock.go: -------------------------------------------------------------------------------- 1 | package common 2 | 3 | import ( 4 | "time" 5 | ) 6 | 7 | type Timer struct { 8 | itimer ITimer 9 | C <-chan time.Time 10 | } 11 | 12 | func NewTimer(itm ITimer) Timer { 13 | return Timer{itm, make(chan time.Time)} 14 | } 15 | 16 | func NewTimerWithChan(itm ITimer, c chan time.Time) Timer { 17 | return Timer{itm, c} 18 | } 19 | 20 | func (timer *Timer) Stop() { 21 | timer.itimer.Stop() 22 | } 23 | 24 | type ITimer interface { 25 | Stop() bool 26 | } 27 | 28 | type Clock interface { 29 | Now() time.Time 30 | AfterFunc(d time.Duration, f func()) Timer 31 | NewTimer(d time.Duration) Timer 32 | Sleep(d time.Duration) 33 | } 34 | 35 | type GoTimeClock struct { 36 | } 37 | 38 | func (cl *GoTimeClock) Now() time.Time { 39 | return time.Now() 40 | } 41 | 42 | func (cl *GoTimeClock) AfterFunc(d time.Duration, f func()) Timer { 43 | return NewTimer(time.AfterFunc(d, f)) 44 | } 45 | 46 | func (cl *GoTimeClock) NewTimer(d time.Duration) Timer { 47 | return NewTimer(time.NewTimer(d)) 48 | } 49 | 50 | func (cl *GoTimeClock) Sleep(d time.Duration) { 51 | time.Sleep(d) 52 | } 53 | 54 | func UnixMicroFromTime(t time.Time) int64 { 55 | return t.UnixNano() / int64(time.Microsecond) 56 | } 57 | -------------------------------------------------------------------------------- /common/codec/chain.go: -------------------------------------------------------------------------------- 1 | package codec 2 | 3 | import ( 4 | "io" 5 | ) 6 | 7 | func Marshal(w io.Writer, v interface{}) error { 8 | return BC.Marshal(w, v) 9 | } 10 | 11 | func Unmarshal(r io.Reader, v interface{}) error { 12 | return BC.Unmarshal(r, v) 13 | } 14 | 15 | func NewSimpleEncoder(w io.Writer) EncodeAndCloser { 16 | return BC.NewEncoder(w) 17 | } 18 | 19 | func NewSimpleDecoder(r io.Reader) DecodeAndCloser { 20 | return BC.NewDecoder(r) 21 | } 22 | 23 | func NewEncoderBytes(b *[]byte) EncodeAndCloser { 24 | return BC.NewEncoderBytes(b) 25 | } 26 | 27 | func MarshalToBytes(v interface{}) ([]byte, error) { 28 | return BC.MarshalToBytes(v) 29 | } 30 | 31 | func MustMarshalToBytes(v interface{}) []byte { 32 | return BC.MustMarshalToBytes(v) 33 | } 34 | 35 | func MustUnmarshalFromBytes(b []byte, v interface{}) []byte { 36 | return BC.MustUnmarshalFromBytes(b, v) 37 | } 38 | -------------------------------------------------------------------------------- /common/codec/chain_mp.go: -------------------------------------------------------------------------------- 1 | // +build msgpack 2 | 3 | package codec 4 | 5 | var ( 6 | BC = MP 7 | ) 8 | -------------------------------------------------------------------------------- /common/codec/chain_rlp.go: -------------------------------------------------------------------------------- 1 | // +build !msgpack 2 | 3 | package codec 4 | 5 | var ( 6 | BC = RLP 7 | ) 8 | -------------------------------------------------------------------------------- /common/compress.go: -------------------------------------------------------------------------------- 1 | package common 2 | 3 | import ( 4 | "bytes" 5 | "io" 6 | 7 | "github.com/icon-project/goloop/common/lzw" 8 | ) 9 | 10 | func Compress(bs []byte) []byte { 11 | if len(bs) == 0 { 12 | return []byte{} 13 | } 14 | wb := bytes.NewBuffer(nil) 15 | fd := lzw.NewWriter(wb, lzw.MSB, 8) 16 | _, _ = fd.Write(bs) 17 | _ = fd.Close() 18 | return wb.Bytes() 19 | } 20 | 21 | func Decompress(bs []byte) []byte { 22 | if len(bs) == 0 { 23 | return []byte{} 24 | } 25 | wb := bytes.NewBuffer(bs) 26 | fd := lzw.NewReader(wb, lzw.MSB, 8) 27 | c, _ := io.ReadAll(fd) 28 | _ = fd.Close() 29 | return c 30 | } 31 | -------------------------------------------------------------------------------- /common/containerdb/vardb.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 ICON Foundation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package containerdb 18 | 19 | type VarDB struct { 20 | WritableValue 21 | } 22 | 23 | func NewVarDB(source interface{}, key KeyBuilder) *VarDB { 24 | store := ToStoreState(source) 25 | return &VarDB{store.At(key.Build())} 26 | } 27 | -------------------------------------------------------------------------------- /common/crypto/hash.go: -------------------------------------------------------------------------------- 1 | package crypto 2 | 3 | import ( 4 | "crypto/sha256" 5 | 6 | "golang.org/x/crypto/sha3" 7 | ) 8 | 9 | // SHA3Sum256 returns the SHA3-256 digest of the data 10 | func SHA3Sum256(m []byte) []byte { 11 | d := sha3.Sum256(m) 12 | return d[:] 13 | } 14 | 15 | // SHASum256 returns the SHA256 digest of the data 16 | func SHASum256(m []byte) []byte { 17 | d := sha256.Sum256(m) 18 | return d[:] 19 | } 20 | -------------------------------------------------------------------------------- /common/db/null_db.go: -------------------------------------------------------------------------------- 1 | package db 2 | 3 | type nullDB struct { 4 | } 5 | 6 | func (*nullDB) GetBucket(id BucketID) (Bucket, error) { 7 | return &nullBucket{}, nil 8 | } 9 | 10 | func (*nullDB) Close() error { 11 | return nil 12 | } 13 | 14 | type nullBucket struct { 15 | } 16 | 17 | func (*nullBucket) Get(key []byte) ([]byte, error) { 18 | return nil, nil 19 | } 20 | 21 | func (*nullBucket) Has(key []byte) (bool, error) { 22 | return false, nil 23 | } 24 | 25 | func (*nullBucket) Set(key []byte, value []byte) error { 26 | panic("NullBucket.Set() Unsupported") 27 | } 28 | 29 | func (*nullBucket) Delete(key []byte) error { 30 | panic("NullBucket.Delete() Unsupported") 31 | } 32 | 33 | func NewNullDB() *nullDB { 34 | return &nullDB{} 35 | } 36 | -------------------------------------------------------------------------------- /common/errors.go: -------------------------------------------------------------------------------- 1 | package common 2 | 3 | import ( 4 | "github.com/icon-project/goloop/common/errors" 5 | ) 6 | 7 | var ( 8 | ErrUnknown = errors.ErrUnknown 9 | ErrIllegalArgument = errors.ErrIllegalArgument 10 | ErrInvalidState = errors.ErrInvalidState 11 | ErrUnsupported = errors.ErrUnsupported 12 | ErrNotFound = errors.ErrNotFound 13 | ) 14 | -------------------------------------------------------------------------------- /common/hexbool.go: -------------------------------------------------------------------------------- 1 | package common 2 | 3 | import ( 4 | "encoding/json" 5 | 6 | "github.com/icon-project/goloop/common/codec" 7 | "github.com/icon-project/goloop/common/errors" 8 | ) 9 | 10 | type HexBool struct { 11 | Value bool 12 | } 13 | 14 | func (i *HexBool) String() string { 15 | if i.Value { 16 | return "0x1" 17 | } else { 18 | return "0x0" 19 | } 20 | } 21 | 22 | func (i *HexBool) MarshalJSON() ([]byte, error) { 23 | return json.Marshal(i.String()) 24 | } 25 | 26 | func (i *HexBool) UnmarshalJSON(b []byte) (err error) { 27 | var s string 28 | if err = json.Unmarshal(b, &s); err != nil { 29 | s = string(b) 30 | } 31 | if i.Value, err = ParseHexBool(s); err != nil { 32 | return err 33 | } 34 | return nil 35 | } 36 | 37 | func (i *HexBool) RLPEncodeSelf(e codec.Encoder) error { 38 | return e.Encode(i.Value) 39 | } 40 | 41 | func (i *HexBool) RLPDecodeSelf(d codec.Decoder) error { 42 | return d.Decode(&i.Value) 43 | } 44 | 45 | func ParseHexBool(s string) (bool, error) { 46 | if s == "0x1" { 47 | return true, nil 48 | } else if s == "0x0" { 49 | return false, nil 50 | } else { 51 | return false, errors.New("invalid value") 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /common/hexbytes_test.go: -------------------------------------------------------------------------------- 1 | package common 2 | 3 | import ( 4 | "encoding/json" 5 | "testing" 6 | 7 | "github.com/stretchr/testify/assert" 8 | ) 9 | 10 | func Test_RawHexBytes_UnmarshalJSON(t *testing.T) { 11 | var hb RawHexBytes 12 | 13 | err := json.Unmarshal([]byte("null"), &hb) 14 | if err != nil { 15 | t.Errorf("Fail to unmarshal json null err=%+v", err) 16 | } 17 | assert.Nil(t, hb) 18 | } 19 | 20 | func Test_RawHexBytes_MarshalJSON(t *testing.T) { 21 | var hb RawHexBytes 22 | bs, err := json.Marshal(hb) 23 | if err != nil { 24 | t.Errorf("Fail to marshal json null err=%+v", err) 25 | } 26 | assert.Equal(t, []byte("null"), bs) 27 | } 28 | 29 | func Test_HexBytes_UnmarshalJSON(t *testing.T) { 30 | var hb HexBytes 31 | 32 | err := json.Unmarshal([]byte("null"), &hb) 33 | if err != nil { 34 | t.Errorf("Fail to unmarshal json null err=%+v", err) 35 | } 36 | assert.Nil(t, hb) 37 | } 38 | 39 | func Test_HexBytes_MarshalJSON(t *testing.T) { 40 | var hb HexBytes 41 | bs, err := json.Marshal(hb) 42 | if err != nil { 43 | t.Errorf("Fail to marshal json null err=%+v", err) 44 | } 45 | assert.Equal(t, []byte("null"), bs) 46 | } 47 | -------------------------------------------------------------------------------- /common/intconv/int.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 ICON Foundation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | 18 | package intconv 19 | 20 | import "math/big" 21 | 22 | var bigIntZero big.Int 23 | var BigIntZero = &bigIntZero 24 | 25 | func BigIntSafe(i *big.Int) *big.Int { 26 | if i != nil { 27 | return i 28 | } else { 29 | return BigIntZero 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /common/intconv/int_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 ICON Foundation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | 18 | package intconv 19 | 20 | import ( 21 | "math/big" 22 | "testing" 23 | 24 | "github.com/stretchr/testify/assert" 25 | ) 26 | 27 | func TestBigIntSafe(t *testing.T) { 28 | assert.True(t, BigIntZero.Cmp(BigIntSafe(nil)) == 0) 29 | value := big.NewInt(1238) 30 | assert.True(t, BigIntSafe(value) == value) 31 | } -------------------------------------------------------------------------------- /common/json.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 ICON Foundation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package common 18 | 19 | import ( 20 | "bytes" 21 | "encoding/json" 22 | ) 23 | 24 | func CompactJSON(js []byte) ([]byte, error) { 25 | b := bytes.NewBuffer(nil) 26 | if err := json.Compact(b, js); err != nil { 27 | return nil, err 28 | } else { 29 | return b.Bytes(), nil 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /common/legacy/loopchain_test.go: -------------------------------------------------------------------------------- 1 | // +build ignore 2 | 3 | package legacy 4 | 5 | import ( 6 | "encoding/json" 7 | "os" 8 | "testing" 9 | ) 10 | 11 | func TestLoopChainDB_GetReceiptByTransaction(t *testing.T) { 12 | dbase, err := OpenDatabase("./data/testnet/block", "") 13 | if err != nil { 14 | t.Errorf("Fail to open database err=%+v", err) 15 | return 16 | } 17 | 18 | for i := 1; i < 10; i++ { 19 | blk, err := dbase.GetBlockByHeight(i) 20 | if err != nil { 21 | t.Errorf("Fail to get block err=%+v", err) 22 | return 23 | } 24 | txl := blk.NormalTransactions() 25 | for i := txl.Iterator(); i.Has(); i.Next() { 26 | tx, _, err := i.Get() 27 | if err != nil { 28 | t.Errorf("Fail to get transaction err=%+v", err) 29 | continue 30 | } 31 | r, err := dbase.GetReceiptByTransaction(tx.ID()) 32 | if err != nil { 33 | t.Errorf("Fail to get receipt for tx=%x err=%+v", tx.ID(), err) 34 | continue 35 | } 36 | 37 | enc := json.NewEncoder(os.Stdout) 38 | enc.SetIndent("", " ") 39 | enc.Encode(r) 40 | os.Stdout.Sync() 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /common/log/writer.go: -------------------------------------------------------------------------------- 1 | package log 2 | 3 | import ( 4 | "io" 5 | 6 | "gopkg.in/natefinch/lumberjack.v2" 7 | ) 8 | 9 | type WriterConfig struct { 10 | Filename string `json:"filename"` 11 | MaxSize int `json:"maxsize"` 12 | MaxAge int `json:"maxage"` 13 | MaxBackups int `json:"maxbackups"` 14 | LocalTime bool `json:"localtime"` 15 | Compress bool `json:"compress"` 16 | } 17 | 18 | func NewWriter(cfg *WriterConfig) (io.Writer, error) { 19 | return &lumberjack.Logger{ 20 | Filename: cfg.Filename, 21 | MaxSize: cfg.MaxSize, 22 | MaxAge: cfg.MaxAge, 23 | MaxBackups: cfg.MaxBackups, 24 | LocalTime: cfg.LocalTime, 25 | Compress: cfg.Compress, 26 | }, nil 27 | } 28 | -------------------------------------------------------------------------------- /common/signature_test.go: -------------------------------------------------------------------------------- 1 | package common 2 | 3 | import ( 4 | "bytes" 5 | "testing" 6 | 7 | "github.com/icon-project/goloop/common/codec" 8 | "github.com/icon-project/goloop/common/crypto" 9 | ) 10 | 11 | func TestSignatureCoding(t *testing.T) { 12 | obs := []byte("01234567890123456789012345678901234567890123456789012345678901234") 13 | var sig Signature 14 | var err error 15 | sig.Signature, err = crypto.ParseSignature(obs) 16 | if err != nil { 17 | t.Fail() 18 | } 19 | sigBS, err := codec.MarshalToBytes(&sig) 20 | if err != nil { 21 | t.Fail() 22 | } 23 | var sig2 Signature 24 | _, err = codec.UnmarshalFromBytes(sigBS, &sig2) 25 | if err != nil { 26 | t.Fail() 27 | } 28 | rsv, err := sig2.Signature.SerializeRSV() 29 | if err != nil { 30 | t.Fail() 31 | } 32 | if !bytes.Equal(obs, rsv) { 33 | t.Fail() 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /common/string.go: -------------------------------------------------------------------------------- 1 | package common 2 | 3 | func StrLeft(n int, s string) string { 4 | if len(s) > n { 5 | return string([]byte(s)[0:n]) 6 | } 7 | return s 8 | } 9 | -------------------------------------------------------------------------------- /common/trie/config.go: -------------------------------------------------------------------------------- 1 | package trie 2 | 3 | const ( 4 | ConfigUseKeccak256 = false 5 | ) 6 | -------------------------------------------------------------------------------- /common/trie/ompt/bytesobject.go: -------------------------------------------------------------------------------- 1 | package ompt 2 | 3 | import ( 4 | "bytes" 5 | "fmt" 6 | 7 | "github.com/icon-project/goloop/common/db" 8 | "github.com/icon-project/goloop/common/log" 9 | "github.com/icon-project/goloop/common/merkle" 10 | "github.com/icon-project/goloop/common/trie" 11 | ) 12 | 13 | type bytesObject []byte 14 | 15 | func (o bytesObject) Bytes() []byte { 16 | return o 17 | } 18 | 19 | func (o bytesObject) Reset(db db.Database, k []byte) error { 20 | log.Panicln("Bytes object can't RESET!!") 21 | return nil 22 | } 23 | 24 | func (o bytesObject) Flush() error { 25 | // Nothing to do because it comes from database itself. 26 | return nil 27 | } 28 | 29 | func (o bytesObject) String() string { 30 | return fmt.Sprintf("[%x]", []byte(o)) 31 | } 32 | 33 | func (o bytesObject) Equal(n trie.Object) bool { 34 | if bo, ok := n.(bytesObject); n != nil && !ok { 35 | return false 36 | } else { 37 | return bytes.Equal(bo, o) 38 | } 39 | } 40 | 41 | func (o bytesObject) Resolve(builder merkle.Builder) error { 42 | return nil 43 | } 44 | 45 | func (o bytesObject) ClearCache() { 46 | // nothing to do, because it doesn't have belonging objects. 47 | } 48 | -------------------------------------------------------------------------------- /common/wallet/wallet.go: -------------------------------------------------------------------------------- 1 | package wallet 2 | 3 | import ( 4 | "github.com/icon-project/goloop/common" 5 | "github.com/icon-project/goloop/common/crypto" 6 | "github.com/icon-project/goloop/module" 7 | ) 8 | 9 | type softwareWallet struct { 10 | skey *crypto.PrivateKey 11 | pkey *crypto.PublicKey 12 | } 13 | 14 | func (w *softwareWallet) Address() module.Address { 15 | return common.NewAccountAddressFromPublicKey(w.pkey) 16 | } 17 | 18 | func (w *softwareWallet) Sign(data []byte) ([]byte, error) { 19 | sig, err := crypto.NewSignature(data, w.skey) 20 | if err != nil { 21 | return nil, err 22 | } 23 | return sig.SerializeRSV() 24 | } 25 | 26 | func (w *softwareWallet) PublicKey() []byte { 27 | return w.pkey.SerializeCompressed() 28 | } 29 | 30 | func New() module.Wallet { 31 | sk, pk := crypto.GenerateKeyPair() 32 | return &softwareWallet{ 33 | skey: sk, 34 | pkey: pk, 35 | } 36 | } 37 | 38 | func NewFromPrivateKey(sk *crypto.PrivateKey) (module.Wallet, error) { 39 | pk := sk.PublicKey() 40 | return &softwareWallet{ 41 | skey: sk, 42 | pkey: pk, 43 | }, nil 44 | } 45 | -------------------------------------------------------------------------------- /consensus/commitcache.go: -------------------------------------------------------------------------------- 1 | package consensus 2 | 3 | import ( 4 | "container/list" 5 | 6 | "github.com/icon-project/goloop/module" 7 | ) 8 | 9 | type commit struct { 10 | height int64 11 | commitVotes module.CommitVoteSet 12 | votes *VoteList 13 | blockPartSet PartSet 14 | } 15 | 16 | type commitCache struct { 17 | cap int 18 | heightMap map[int64]*list.Element 19 | mru *list.List 20 | } 21 | 22 | func newCommitCache(cap int) *commitCache { 23 | return &commitCache{ 24 | cap: cap, 25 | heightMap: make(map[int64]*list.Element), 26 | mru: list.New(), 27 | } 28 | } 29 | 30 | func (c *commitCache) Put(cm *commit) { 31 | if c.mru.Len() == c.cap { 32 | cm := c.mru.Remove(c.mru.Back()).(*commit) 33 | delete(c.heightMap, cm.height) 34 | } 35 | e := c.mru.PushFront(cm) 36 | c.heightMap[cm.height] = e 37 | } 38 | 39 | func (c *commitCache) GetByHeight(h int64) *commit { 40 | if e, ok := c.heightMap[h]; ok { 41 | c.mru.MoveToFront(e) 42 | return e.Value.(*commit) 43 | } 44 | return nil 45 | } 46 | 47 | // for test 48 | func (c *commitCache) _getMRU() *list.List { 49 | return c.mru 50 | } 51 | -------------------------------------------------------------------------------- /consensus/commitcache_test.go: -------------------------------------------------------------------------------- 1 | package consensus 2 | 3 | import ( 4 | "container/list" 5 | "testing" 6 | 7 | "github.com/stretchr/testify/assert" 8 | ) 9 | 10 | func assertListHeights(t *testing.T, l *list.List, h ...int64) { 11 | assert.Equal(t, l.Len(), len(h)) 12 | i := 0 13 | for e := l.Front(); e != nil; e = e.Next() { 14 | assert.Equal(t, e.Value.(*commit).height, h[i]) 15 | i++ 16 | } 17 | } 18 | 19 | func TestCache_Simple(t *testing.T) { 20 | c := newCommitCache(3) 21 | c.Put(&commit{height: 0}) 22 | cm := c.GetByHeight(0) 23 | assert.NotNil(t, cm) 24 | } 25 | 26 | func TestCache_Simple2(t *testing.T) { 27 | c := newCommitCache(3) 28 | c.Put(&commit{height: 0}) 29 | c.Put(&commit{height: 1}) 30 | c.Put(&commit{height: 2}) 31 | c.GetByHeight(0) 32 | c.Put(&commit{height: 3}) 33 | assertListHeights(t, c._getMRU(), 3, 0, 2) 34 | } 35 | -------------------------------------------------------------------------------- /consensus/step.go: -------------------------------------------------------------------------------- 1 | package consensus 2 | 3 | import "fmt" 4 | 5 | type step int 6 | 7 | const ( 8 | stepNewHeight step = iota 9 | stepTransactionWait 10 | stepNewRound 11 | stepPropose 12 | stepPrevote 13 | stepPrevoteWait 14 | stepPrecommit 15 | stepPrecommitWait 16 | stepCommit 17 | ) 18 | 19 | func (step step) String() string { 20 | switch step { 21 | case stepNewHeight: 22 | return "stepNewHeight" 23 | case stepTransactionWait: 24 | return "stepTransactionWait" 25 | case stepNewRound: 26 | return "stepNewRound" 27 | case stepPropose: 28 | return "stepPropose" 29 | case stepPrevote: 30 | return "stepPrevote" 31 | case stepPrevoteWait: 32 | return "stepPrevoteWait" 33 | case stepPrecommit: 34 | return "stepPrecommit" 35 | case stepPrecommitWait: 36 | return "stepPrecommitWait" 37 | case stepCommit: 38 | return "stepCommit" 39 | default: 40 | return fmt.Sprintf("step %d", step) 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /doc/.vuepress/hometags: -------------------------------------------------------------------------------- 1 | --- 2 | home: true 3 | heroText: Goloop Document 4 | tagline: Goloop Document 5 | actionText: Get Started → 6 | actionLink: /build 7 | --- -------------------------------------------------------------------------------- /doc/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "scripts": { 3 | "doc:dev": "./node_modules/.bin/vuepress dev ./", 4 | "doc:build": "./node_modules/.bin/vuepress build ./", 5 | "doc:serve": "./node_modules/.bin/serve --single .vuepress/dist", 6 | "api:gen": "./node_modules/.bin/widdershins -l --summary goloop_admin_api.yaml -o goloop_admin_api.md && ../bin/goloop doc goloop_cli.md" 7 | }, 8 | "license": "MIT", 9 | "devDependencies": { 10 | "serve": "^11.0.0", 11 | "vuepress": "^1.0.0-alpha.48", 12 | "widdershins": "^3.6.7" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /docker/base/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG ALPINE_VERSION 2 | ARG IMAGE_PY_DEPS 3 | ARG IMAGE_ROCKSDB_DEPS 4 | ARG IMAGE_PY_DEPS 5 | ARG BASE 6 | FROM ${IMAGE_PY_DEPS} as base-py 7 | 8 | FROM alpine:${ALPINE_VERSION} as base-java 9 | RUN apk add --no-cache openjdk11-jre-headless 10 | 11 | FROM base-py as base-all 12 | RUN apk add --no-cache openjdk11-jre-headless 13 | 14 | FROM ${IMAGE_ROCKSDB_DEPS} as rocksdb 15 | 16 | ARG BASE 17 | FROM ${BASE} 18 | ARG ALPINE_UPDATES 19 | LABEL MAINTAINER="t_arch@iconloop.com" 20 | RUN apk add --update --no-cache zlib bzip2-dev snappy lz4-dev zstd-dev libtbb gflags libc6-compat ${ALPINE_UPDATES} 21 | COPY --from=rocksdb /work/rocksdb/lib /usr/lib/ 22 | 23 | ARG GOLOOP_BASE_SHA 24 | LABEL GOLOOP_BASE_SHA="$GOLOOP_BASE_SHA" 25 | -------------------------------------------------------------------------------- /docker/base/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | PRE_PWD=$(pwd) 5 | WORKDIR=$(dirname "$(readlink -f ${0})") 6 | cd $WORKDIR 7 | 8 | export IMAGE_PY_DEPS=${IMAGE_PY_DEPS:-goloop/py-deps:latest} 9 | export IMAGE_ROCKSDB_DEPS=${IMAGE_ROCKSDB_DEPS:-goloop/rocksdb-deps:latest} 10 | 11 | ENGINE=${1} 12 | IMAGE_SUFFIX=-${ENGINE} 13 | IMAGE_BASE=${IMAGE_BASE:-goloop/base-${ENGINE}latest} 14 | 15 | ./update.sh "${ENGINE}" "${IMAGE_BASE}" ../.. 16 | 17 | cd $PRE_PWD 18 | -------------------------------------------------------------------------------- /docker/build-deps/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG IMAGE_GO_DEPS 2 | ARG IMAGE_ROCKSDB_DEPS 3 | FROM ${IMAGE_ROCKSDB_DEPS} as rocksdb 4 | 5 | ARG IMAGE_GO_DEPS 6 | FROM ${IMAGE_GO_DEPS} 7 | 8 | RUN apk add --update --no-cache zlib-dev bzip2-dev snappy-dev lz4-dev zstd-dev libtbb-dev gflags-dev 9 | COPY --from=rocksdb /work/rocksdb/lib /usr/lib/ 10 | COPY --from=rocksdb /work/rocksdb/include /usr/include/ 11 | 12 | ARG GOLOOP_BUILDDEP_SHA 13 | LABEL GOLOOP_BUILDDEP_SHA="$GOLOOP_BUILDDEP_SHA" -------------------------------------------------------------------------------- /docker/build-deps/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | PRE_PWD=$(pwd) 5 | WORKDIR=$(dirname "$(readlink -f ${0})") 6 | cd $WORKDIR 7 | 8 | export IMAGE_GO_DEPS=${IMAGE_GO_DEPS:-goloop/go-deps:latest} 9 | export IMAGE_PY_DEPS=${IMAGE_PY_DEPS:-goloop/py-deps:latest} 10 | export IMAGE_JAVA_DEPS=${IMAGE_JAVA_DEPS:-goloop/java-deps:latest} 11 | export IMAGE_ROCKSDB_DEPS=${IMAGE_ROCKSDB_DEPS:-goloop/rocksdb-deps:latest} 12 | 13 | if [ $# -lt 1 ] ; then 14 | echo "Usage: $0 " 15 | echo "\t : build, go, py, java, rocksdb" 16 | return 1 17 | fi 18 | TARGET=${1} 19 | case $TARGET in 20 | go) 21 | IMAGE_DEPS=${IMAGE_GO_DEPS} 22 | ;; 23 | py) 24 | IMAGE_DEPS=${IMAGE_PY_DEPS} 25 | ;; 26 | java) 27 | IMAGE_DEPS=${IMAGE_JAVA_DEPS} 28 | ;; 29 | rocksdb) 30 | IMAGE_DEPS=${IMAGE_ROCKSDB_DEPS} 31 | ;; 32 | build) 33 | IMAGE_DEPS=${IMAGE_BUILD_DEPS} 34 | ;; 35 | *) 36 | ;; 37 | esac 38 | if [ -z "${IMAGE_DEPS}" ]; then 39 | IMAGE_DEPS=goloop/${TARGET}-deps:latest 40 | fi 41 | 42 | ./update.sh ${TARGET} "${IMAGE_DEPS}" ../.. 43 | 44 | cd $PRE_PWD 45 | -------------------------------------------------------------------------------- /docker/build-deps/go.Dockerfile: -------------------------------------------------------------------------------- 1 | ARG GOLANG_VERSION 2 | ARG ALPINE_VERSION 3 | FROM golang:${GOLANG_VERSION}-alpine${ALPINE_VERSION} 4 | RUN apk add make git build-base 5 | RUN if [[ $(uname -m | grep -E '^arm|^aarch' | wc -l) == 1 ]]; then apk add binutils-gold; fi 6 | ENV GO111MODULE on 7 | 8 | ARG GOLOOP_GOMOD_SHA 9 | LABEL GOLOOP_GOMOD_SHA="$GOLOOP_GOMOD_SHA" 10 | ADD go.mod go.sum /goloop/ 11 | WORKDIR /goloop 12 | 13 | RUN git config --global --add safe.directory /work 14 | 15 | RUN echo "go mod download $GOLOOP_GOMOD_SHA" && go mod download 16 | -------------------------------------------------------------------------------- /docker/build-deps/java.Dockerfile: -------------------------------------------------------------------------------- 1 | ARG ALPINE_VERSION 2 | FROM alpine:${ALPINE_VERSION} 3 | 4 | RUN apk add --no-cache openjdk11-jdk build-base 5 | ENV JAVA_HOME /usr/lib/jvm/default-jvm 6 | 7 | ARG GOLOOP_JADEP_SHA 8 | LABEL GOLOOP_JADEP_SHA="$GOLOOP_JADEP_SHA" 9 | COPY gradlew /goloop/ 10 | COPY gradle/ /goloop/gradle/ 11 | WORKDIR /goloop 12 | 13 | RUN ./gradlew tasks \ 14 | && find ~/.gradle/ -name "*.lock" -type f -delete 15 | 16 | CMD ["/bin/sh"] 17 | -------------------------------------------------------------------------------- /docker/build-deps/py.Dockerfile: -------------------------------------------------------------------------------- 1 | ARG PYTHON_VERSION 2 | ARG ALPINE_VERSION 3 | FROM python:${PYTHON_VERSION}-alpine${ALPINE_VERSION} 4 | 5 | # required by 'pip install coincurve cryptography' 6 | RUN apk add --no-cache build-base libffi-dev openssl-dev 7 | 8 | # setup python env 9 | ADD requirements.txt /goloop/ 10 | WORKDIR /goloop 11 | ARG PYTHON_UPDATES 12 | RUN pip install --upgrade pip ${PYTHON_UPDATES} && \ 13 | python3 -m venv /goloop/venv && \ 14 | source /goloop/venv/bin/activate && \ 15 | pip install --upgrade pip wheel ${PYTHON_UPDATES} && \ 16 | pip install -r /goloop/requirements.txt 17 | 18 | ARG GOLOOP_PYDEP_SHA 19 | LABEL GOLOOP_PYDEP_SHA="$GOLOOP_PYDEP_SHA" 20 | 21 | # entrypoint 22 | RUN { \ 23 | echo '#!/bin/sh'; \ 24 | echo 'set -e'; \ 25 | echo 'source /goloop/venv/bin/activate'; \ 26 | echo 'exec "$@"'; \ 27 | } > /entrypoint \ 28 | && chmod +x /entrypoint 29 | ENTRYPOINT ["/entrypoint"] 30 | 31 | CMD ["/bin/sh"] 32 | -------------------------------------------------------------------------------- /docker/build-deps/rocksdb.Dockerfile: -------------------------------------------------------------------------------- 1 | ARG ALPINE_VERSION 2 | FROM alpine:${ALPINE_VERSION} 3 | 4 | RUN apk add --update --no-cache build-base linux-headers git cmake bash perl 5 | RUN apk add --update --no-cache zlib-dev bzip2-dev snappy-dev lz4-dev zstd-dev libtbb-dev gflags-dev 6 | 7 | WORKDIR /work 8 | RUN mkdir -p /work 9 | 10 | ARG ROCKSDB_VERSION 11 | LABEL ROCKSDB_VERSION="$ROCKSDB_VERSION" 12 | RUN cd /work && \ 13 | git clone https://github.com/facebook/rocksdb.git && \ 14 | cd rocksdb && \ 15 | git checkout ${ROCKSDB_VERSION} && \ 16 | PORTABLE=1 make shared_lib 17 | 18 | RUN cd /work/rocksdb && \ 19 | mkdir lib && \ 20 | cp -P librocksdb.so* lib/ 21 | 22 | ARG GOLOOP_ROCKSDBDEP_SHA 23 | LABEL GOLOOP_ROCKSDBDEP_SHA="$GOLOOP_ROCKSDBDEP_SHA" 24 | 25 | -------------------------------------------------------------------------------- /docker/function.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | get_hash_of_files() { 4 | cat "$@" | sha1sum | cut -d " " -f1 5 | } 6 | 7 | get_hash_of_any() { 8 | for item in "$@"; do 9 | if [ "${item#@}" == "${item}" ] ; then 10 | echo "${item}" 11 | else 12 | cat "${item#@}" 13 | fi 14 | done | sha1sum | cut -d " " -f1 15 | } 16 | 17 | get_label_of_image() { 18 | local LABEL=$1 19 | local TAG=$2 20 | docker image inspect -f "{{.Config.Labels.${LABEL}}}" ${TAG} 2> /dev/null || echo 'none' 21 | } 22 | 23 | get_id_with_hash() { 24 | local REPO=$1 25 | local LABEL=$2 26 | local HASH=$3 27 | docker images --filter="reference=${REPO}" --filter="label=${LABEL}=${HASH}" --format="{{.ID}}" | head -n 1 28 | } -------------------------------------------------------------------------------- /docker/gochain-icon/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG IMAGE_BASE 2 | FROM ${IMAGE_BASE} 3 | LABEL MAINTAINER="t_icondev@iconloop.com" 4 | 5 | ARG GOCHAIN_ICON_VERSION 6 | LABEL GOCHAIN_ICON_VERSION="$GOCHAIN_ICON_VERSION" 7 | 8 | # install python executor 9 | ADD dist/pyee /goloop/pyee 10 | RUN /entrypoint python3 -m pip -q install /goloop/pyee/iconee-*.whl && \ 11 | rm -rf /goloop/pyee 12 | 13 | # install java executor 14 | ARG JAVAEE_VERSION 15 | ADD dist/execman-${JAVAEE_VERSION}.zip /goloop/ 16 | RUN unzip -q /goloop/execman-${JAVAEE_VERSION}.zip -d /goloop/ && \ 17 | mv /goloop/execman-${JAVAEE_VERSION} /goloop/execman && \ 18 | rm -f /goloop/execman-*.zip 19 | ENV JAVAEE_BIN /goloop/execman/bin/execman 20 | 21 | # install gochain and other stuff 22 | ADD dist/bin/* /goloop/bin/ 23 | ENV PATH $PATH:/goloop/bin 24 | 25 | # container configuration 26 | WORKDIR /goloop 27 | EXPOSE 9080/tcp 28 | EXPOSE 8080/tcp 29 | 30 | ADD run.sh /goloop/ 31 | CMD /goloop/run.sh 32 | -------------------------------------------------------------------------------- /docker/gochain-icon/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Copyright 2021 ICON Foundation 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | 18 | set -e 19 | 20 | PRE_PWD=$(pwd) 21 | WORKDIR=$(dirname "$(readlink -f ${0})") 22 | cd $WORKDIR 23 | 24 | export IMAGE_BASE=${IMAGE_BASE:-goloop/base-all:latest} 25 | 26 | export GOCHAIN_ICON_VERSION=${GOCHAIN_ICON_VERSION:-$(git describe --always --tags --dirty)} 27 | IMAGE_GOCHAIN_ICON=${IMAGE_GOCHAIN_ICON:-goloop/gochain-icon:latest} 28 | 29 | ./update.sh "${IMAGE_GOCHAIN_ICON}" ../.. 30 | 31 | cd $PRE_PWD 32 | -------------------------------------------------------------------------------- /docker/gochain/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG IMAGE_BASE 2 | FROM ${IMAGE_BASE} 3 | LABEL MAINTAINER="t_arch@iconloop.com" 4 | 5 | ARG GOCHAIN_VERSION 6 | LABEL GOCHAIN_VERSION="$GOCHAIN_VERSION" 7 | 8 | # install python executor 9 | ADD dist/pyexec-*.whl /goloop/ 10 | RUN /entrypoint python3 -m pip -q install /goloop/pyexec-*.whl && \ 11 | rm -f /goloop/pyexec-*.whl 12 | 13 | # install java executor 14 | ARG JAVAEE_VERSION 15 | ADD dist/execman-${JAVAEE_VERSION}.zip /goloop/ 16 | RUN unzip -q /goloop/execman-${JAVAEE_VERSION}.zip -d /goloop/ && \ 17 | mv /goloop/execman-${JAVAEE_VERSION} /goloop/execman && \ 18 | rm -f /goloop/execman-*.zip 19 | ENV JAVAEE_BIN /goloop/execman/bin/execman 20 | 21 | # install gochain and other stuff 22 | ADD dist/gochain /goloop/bin/ 23 | ENV PATH $PATH:/goloop/bin 24 | 25 | # container configuration 26 | WORKDIR /goloop 27 | EXPOSE 9080/tcp 28 | EXPOSE 8080/tcp 29 | 30 | ADD run.sh /goloop/ 31 | CMD /goloop/run.sh 32 | -------------------------------------------------------------------------------- /docker/gochain/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | PRE_PWD=$(pwd) 5 | WORKDIR=$(dirname "$(readlink -f ${0})") 6 | cd $WORKDIR 7 | 8 | export IMAGE_BASE=${IMAGE_BASE:-goloop/base-all:latest} 9 | 10 | export GOCHAIN_VERSION=${GOCHAIN_VERSION:-$(git describe --always --tags --dirty)} 11 | IMAGE_GOCHAIN=${IMAGE_GOCHAIN:-goloop/gochain:latest} 12 | 13 | ./update.sh "${IMAGE_GOCHAIN}" ../.. 14 | 15 | cd $PRE_PWD 16 | -------------------------------------------------------------------------------- /docker/goloop-icon/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Copyright 2021 ICON Foundation 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | set -e 18 | 19 | PRE_PWD=$(pwd) 20 | WORKDIR=$(dirname "$(readlink -f ${0})") 21 | cd $WORKDIR 22 | 23 | export IMAGE_BASE=${IMAGE_BASE:-goloop/base-all:latest} 24 | 25 | export GOLOOP_ICON_VERSION=${GOLOOP_ICON_VERSION:-$(git describe --always --tags --dirty)} 26 | IMAGE_GOLOOP_ICON=${IMAGE_GOLOOP_ICON:-goloop-icon:latest} 27 | 28 | ./update.sh "${IMAGE_GOLOOP_ICON}" ../.. 29 | 30 | cd $PRE_PWD 31 | -------------------------------------------------------------------------------- /docker/goloop-icon/icon_genesis.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icon-project/goloop/67f6ff8433cef57fb9785e6065f0c94b8c1a86dd/docker/goloop-icon/icon_genesis.zip -------------------------------------------------------------------------------- /docker/goloop-icon/icon_governance.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icon-project/goloop/67f6ff8433cef57fb9785e6065f0c94b8c1a86dd/docker/goloop-icon/icon_governance.zip -------------------------------------------------------------------------------- /docker/goloop-java/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | PRE_PWD=$(pwd) 5 | WORKDIR=$(dirname "$(readlink -f ${0})") 6 | cd $WORKDIR 7 | 8 | export IMAGE_BASE=${IMAGE_BASE:-goloop/base-java:latest} 9 | 10 | export GOLOOP_VERSION=${GOLOOP_VERSION:-$(git describe --always --tags --dirty)} 11 | IMAGE_GOLOOP_JAVA=${IMAGE_GOLOOP_JAVA:-goloop-java:latest} 12 | 13 | ./update.sh "${IMAGE_GOLOOP_JAVA}" ../.. 14 | 15 | cd $PRE_PWD 16 | -------------------------------------------------------------------------------- /docker/goloop-py/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | PRE_PWD=$(pwd) 5 | WORKDIR=$(dirname "$(readlink -f ${0})") 6 | cd $WORKDIR 7 | 8 | export IMAGE_BASE=${IMAGE_BASE:-goloop/base-py:latest} 9 | 10 | export GOLOOP_VERSION=${GOLOOP_VERSION:-$(git describe --always --tags --dirty)} 11 | IMAGE_GOLOOP_PY=${IMAGE_GOLOOP_PY:-goloop-py:latest} 12 | 13 | ./update.sh "${IMAGE_GOLOOP_PY}" ../.. 14 | 15 | cd $PRE_PWD 16 | -------------------------------------------------------------------------------- /docker/goloop/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | PRE_PWD=$(pwd) 5 | WORKDIR=$(dirname "$(readlink -f ${0})") 6 | cd $WORKDIR 7 | 8 | export IMAGE_BASE=${IMAGE_BASE:-goloop/base-all:latest} 9 | 10 | export GOLOOP_VERSION=${GOLOOP_VERSION:-$(git describe --always --tags --dirty)} 11 | IMAGE_GOLOOP=${IMAGE_GOLOOP:-goloop:latest} 12 | 13 | ./update.sh "${IMAGE_GOLOOP}" ../.. 14 | 15 | cd $PRE_PWD 16 | -------------------------------------------------------------------------------- /docker/lcimport/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG IMAGE_BASE 2 | FROM ${IMAGE_BASE} 3 | LABEL MAINTAINER="t_arch@iconloop.com" 4 | 5 | ARG LCIMPORT_VERSION 6 | LABEL LCIMPORT_VERSION="$LCIMPORT_VERSION" 7 | 8 | # install python executor 9 | ADD dist/pyee /goloop/pyee 10 | RUN /entrypoint python3 -m pip -q install /goloop/pyee/iconee-*.whl && \ 11 | rm -rf /goloop/pyee 12 | 13 | # install java executor 14 | #ARG JAVAEE_VERSION 15 | #ADD dist/execman-${JAVAEE_VERSION}.zip /goloop/ 16 | #RUN unzip -q /goloop/execman-${JAVAEE_VERSION}.zip -d /goloop/ && \ 17 | # mv /goloop/execman-${JAVAEE_VERSION} /goloop/execman && \ 18 | # rm -f /goloop/execman-*.zip 19 | #ENV JAVAEE_BIN /goloop/execman/bin/execman 20 | 21 | # install lcimport and other stuff 22 | ADD dist/bin/* /goloop/bin/ 23 | ENV PATH $PATH:/goloop/bin 24 | 25 | # install genesis governance 26 | ADD icon_governance.zip /goloop/ 27 | 28 | # container configuration 29 | WORKDIR /goloop 30 | VOLUME [ "/goloop/data" ] 31 | 32 | ENV LCIMPORT_DATA="/goloop/data" 33 | 34 | ENV PYEE_VERIFY_PACKAGE="true" 35 | CMD [ "/goloop/bin/lcimport", "executor", "run" ] 36 | -------------------------------------------------------------------------------- /docker/lcimport/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Copyright 2021 ICON Foundation 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | 18 | set -e 19 | 20 | PRE_PWD=$(pwd) 21 | WORKDIR=$(dirname "$(readlink -f ${0})") 22 | cd $WORKDIR 23 | 24 | export IMAGE_BASE=${IMAGE_BASE:-goloop/base-py:latest} 25 | 26 | export LCIMPORT_VERSION=${LCIMPORT_VERSION:-$(git describe --always --tags --dirty)} 27 | IMAGE_LCIMPORT=${IMAGE_LCIMPORT:-goloop/lcimport:latest} 28 | 29 | ./update.sh "${IMAGE_LCIMPORT}" ../.. 30 | 31 | cd $PRE_PWD 32 | -------------------------------------------------------------------------------- /docker/lcimport/icon_governance.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icon-project/goloop/67f6ff8433cef57fb9785e6065f0c94b8c1a86dd/docker/lcimport/icon_governance.zip -------------------------------------------------------------------------------- /docker/lcimport/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # 4 | # Copyright 2021 ICON Foundation 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | export LCIMPORT_STORE_URI="https://ctz.solidwallet.io/api/v3" 20 | 21 | /goloop/bin/lcimport executor run -------------------------------------------------------------------------------- /docker/version.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | GOLANG_VERSION=${GOLANG_VERSION:-1.23.6} 4 | PYTHON_VERSION=${PYTHON_VERSION:-3.8.20} 5 | PYTHON_UPDATES="pip==23.3 setuptools==70.0.0" 6 | ALPINE_VERSION=${ALPINE_VERSION:-3.20} 7 | ALPINE_UPDATES="libexpat>=2.6.4 musl-utils>=1.2.5-r1 libxml2>=2.12.7-r1" 8 | JAVA_VERSION=${JAVA_VERSION:-11.0.26} 9 | ROCKSDB_VERSION=${ROCKSDB_VERSION:-v8.3.3} 10 | -------------------------------------------------------------------------------- /icon/blockv0/common.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 ICON Foundation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package blockv0 18 | 19 | import "github.com/icon-project/goloop/common" 20 | 21 | func intPtrEqual(v1, v2 *int) bool { 22 | if v1 == v2 { 23 | return true 24 | } 25 | if v1 == nil || v2 == nil { 26 | return false 27 | } 28 | return *v1 == *v2 29 | } 30 | 31 | func hexInt64PtrEqual(v1, v2 *common.HexInt64) bool { 32 | if v1 == v2 { 33 | return true 34 | } 35 | if v1 == nil || v2 == nil { 36 | return false 37 | } 38 | return v1.Value == v2.Value 39 | } 40 | 41 | -------------------------------------------------------------------------------- /icon/blockv1/patch1.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icon-project/goloop/67f6ff8433cef57fb9785e6065f0c94b8c1a86dd/icon/blockv1/patch1.bin -------------------------------------------------------------------------------- /icon/blockv1/patch2.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icon-project/goloop/67f6ff8433cef57fb9785e6065f0c94b8c1a86dd/icon/blockv1/patch2.bin -------------------------------------------------------------------------------- /icon/icdb/bucket.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 ICON Foundation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package icdb 18 | 19 | import "github.com/icon-project/goloop/common/db" 20 | 21 | const ( 22 | // IDToHash maps id of a v1 block to hash of the block and root of reps 23 | // to validator list hash 24 | IDToHash db.BucketID = "I" 25 | 26 | // BlockMerkle basically maps node hash to block merkle node for v1 block. 27 | // In addition, it also has merkleTreeData. 28 | BlockMerkle db.BucketID = "H" 29 | ) 30 | -------------------------------------------------------------------------------- /icon/icmodule/errors.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 ICON Foundation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package icmodule 18 | 19 | import ( 20 | "github.com/icon-project/goloop/common/errors" 21 | "github.com/icon-project/goloop/service/scoreresult" 22 | ) 23 | 24 | const ( 25 | IllegalArgumentError errors.Code = scoreresult.RevertedError + iota 26 | DuplicateError 27 | InvalidStateError 28 | NotFoundError 29 | NotReadyError 30 | ) 31 | 32 | const ( 33 | CodeIISS = errors.CodeCritical + errors.CodeSegment * (iota + 1) 34 | ) 35 | 36 | const ( 37 | CalculationFailedError = CodeIISS + iota 38 | ) 39 | -------------------------------------------------------------------------------- /icon/icmodule/prepevent.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 ICON Foundation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package icmodule 18 | 19 | type PRepEvent int 20 | 21 | const ( 22 | PRepEventBlockVote PRepEvent = iota 23 | PRepEventImposePenalty 24 | PRepEventMainIn 25 | PRepEventRequestUnjail 26 | PRepEventTermEnd 27 | PRepEventValidatorOut 28 | ) 29 | -------------------------------------------------------------------------------- /icon/iiss/calculator/type.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 ICON Foundation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package calculator 18 | 19 | type RewardType int 20 | 21 | const ( 22 | RTBlockProduce RewardType = iota 23 | RTPRep 24 | RTVoter 25 | ) 26 | 27 | func (r RewardType) String() string { 28 | switch r { 29 | case RTBlockProduce: 30 | return "BlockProduce" 31 | case RTPRep: 32 | return "PRep" 33 | case RTVoter: 34 | return "Voter" 35 | default: 36 | return "Unknown" 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /icon/iiss/icobject/factory_test.go: -------------------------------------------------------------------------------- 1 | package icobject 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/stretchr/testify/assert" 7 | 8 | "github.com/icon-project/goloop/common/db" 9 | ) 10 | 11 | func TestFactoryOf(t *testing.T) { 12 | dbase := db.NewMapDB() 13 | fac := FactoryOf(dbase) 14 | assert.Nil(t, fac) 15 | 16 | dbase = AttachObjectFactory(dbase, testFactory) 17 | fac = FactoryOf(dbase) 18 | assert.NotNil(t, fac) 19 | } 20 | -------------------------------------------------------------------------------- /icon/iiss/icstate/allprepcache_test.go: -------------------------------------------------------------------------------- 1 | package icstate 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/stretchr/testify/assert" 7 | 8 | "github.com/icon-project/goloop/common/db" 9 | "github.com/icon-project/goloop/common/trie/trie_manager" 10 | "github.com/icon-project/goloop/icon/iiss/icobject" 11 | ) 12 | 13 | func TestAllPrepCache(t *testing.T) { 14 | var err error 15 | database := icobject.AttachObjectFactory(db.NewMapDB(), NewObjectImpl) 16 | tree := trie_manager.NewMutableForObject(database, nil, icobject.ObjectType) 17 | oss := icobject.NewObjectStoreState(tree) 18 | activePRepCache := NewAllPRepCache(oss) 19 | 20 | size := 5 21 | for i := 0; i < size; i ++ { 22 | addr := newDummyAddress(i) 23 | err = activePRepCache.Add(addr) 24 | assert.NoError(t, err) 25 | assert.Equal(t, i + 1, activePRepCache.Size()) 26 | } 27 | 28 | for i := 0; i < size; i++ { 29 | addr := activePRepCache.Get(i) 30 | assert.True(t, addr.Equal(newDummyAddress(i))) 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /icon/iiss/icstate/module.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 ICON Foundation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package icstate 18 | 19 | import "github.com/icon-project/goloop/module" 20 | 21 | type OwnerToNodeMappable interface { 22 | GetNodeByOwner(owner module.Address) module.Address 23 | } 24 | -------------------------------------------------------------------------------- /icon/iiss/module.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 ICON Foundation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package iiss 18 | 19 | import ( 20 | "math/big" 21 | 22 | "github.com/icon-project/goloop/common/db" 23 | "github.com/icon-project/goloop/icon/iiss/icreward" 24 | ) 25 | 26 | type Calculator interface { 27 | Stop() 28 | IsRunningFor(dbase db.Database, back, reward []byte) bool 29 | WaitResult(blockHeight int64) error 30 | TotalReward() *big.Int 31 | Result() *icreward.Snapshot 32 | } 33 | -------------------------------------------------------------------------------- /icon/lcimporter/status.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 ICON Foundation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package lcimporter 18 | 19 | import ( 20 | "fmt" 21 | 22 | "github.com/icon-project/goloop/common/log" 23 | ) 24 | 25 | const ( 26 | CursorUp = "\x1b[1A" 27 | ClearLine = "\x1b[2K" 28 | ) 29 | 30 | var statusDisplay bool 31 | 32 | func Statusf(l log.Logger, format string, args ...interface{}) { 33 | l.Infof(format, args...) 34 | if l.GetConsoleLevel() < log.InfoLevel { 35 | if statusDisplay { 36 | fmt.Print(CursorUp + ClearLine) 37 | } 38 | fmt.Printf(format, args...) 39 | fmt.Print("\n") 40 | statusDisplay = true 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /icon/merkle/hexary/merkleheader.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 ICON Foundation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hexary 18 | 19 | import "fmt" 20 | 21 | type MerkleHeader struct { 22 | RootHash []byte 23 | Leaves int64 24 | } 25 | 26 | func (mh MerkleHeader) String() string { 27 | return fmt.Sprintf("MerkleHeader{%#x,%d}", mh.RootHash, mh.Leaves) 28 | } 29 | -------------------------------------------------------------------------------- /iconee/README.md: -------------------------------------------------------------------------------- 1 | # Python Execution Engine 2 | -------------------------------------------------------------------------------- /iconee/VERSION: -------------------------------------------------------------------------------- 1 | 0.9.8 2 | -------------------------------------------------------------------------------- /iconee/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2021 ICON Foundation 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | -------------------------------------------------------------------------------- /iconee/iconservice/iconscore/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icon-project/goloop/67f6ff8433cef57fb9785e6065f0c94b8c1a86dd/iconee/iconservice/iconscore/__init__.py -------------------------------------------------------------------------------- /iconee/iconservice/iconscore/system.py: -------------------------------------------------------------------------------- 1 | # Copyright 2021 ICON Foundation 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from pyexec.icon_constant import IconNetworkValueType 16 | -------------------------------------------------------------------------------- /iconee/pyexec/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2018 ICON Foundation 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from .service_engine import ServiceEngine 16 | from .iconscore.icon_score_context import IconScoreContext 17 | from .iconscore.icon_score_base import IconScoreBase 18 | from .ipc.proxy import ServiceManagerProxy 19 | -------------------------------------------------------------------------------- /iconee/pyexec/base/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2018 ICON Foundation 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | -------------------------------------------------------------------------------- /iconee/pyexec/database/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2018 ICON Foundation 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | -------------------------------------------------------------------------------- /iconee/pyexec/iconscore/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2018 ICON Foundation 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | -------------------------------------------------------------------------------- /iconee/pyexec/ipc/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2018 ICON Foundation 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from .proxy import * 16 | -------------------------------------------------------------------------------- /iconee/pyexec/logger/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2019 ICON Foundation 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from .logger import Logger, SystemLogger 16 | -------------------------------------------------------------------------------- /iconee/requirements.txt: -------------------------------------------------------------------------------- 1 | msgpack==0.6.2 2 | coincurve==13.0.0 3 | typing_extensions~=3.7.4.2 4 | -------------------------------------------------------------------------------- /javaee/.gitignore: -------------------------------------------------------------------------------- 1 | build/ 2 | .gradle/ 3 | *.orig 4 | *.rej 5 | *~ 6 | *.class 7 | *.o 8 | *.so 9 | -------------------------------------------------------------------------------- /javaee/Makefile: -------------------------------------------------------------------------------- 1 | GRADLE=./gradlew 2 | 3 | javaexec: 4 | @ \ 5 | echo "[#] Building Java executor" ; \ 6 | export GRADLE_USER_HOME=.gradle ; \ 7 | rm -rf exec/build/native ; \ 8 | $(GRADLE) -Prelease app:execman:distZip 9 | 10 | test: 11 | @ \ 12 | echo "[#] Running javaee test" ; \ 13 | export GRADLE_USER_HOME=.gradle ; \ 14 | $(GRADLE) test 15 | 16 | clean: 17 | @ \ 18 | echo "[#] Cleaning javaee" ; \ 19 | $(GRADLE) clean 20 | 21 | .PHONY: test clean 22 | -------------------------------------------------------------------------------- /javaee/api/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'java-library' 2 | 3 | task scoreJavadoc(type: Javadoc) { 4 | source = sourceSets.main.allJava 5 | classpath = sourceSets.main.output 6 | destinationDir = file("${buildDir}/javadoc") 7 | } 8 | 9 | assemble { 10 | dependsOn scoreJavadoc 11 | } 12 | -------------------------------------------------------------------------------- /javaee/api/src/java/score/BranchDB.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 ICON Foundation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package score; 18 | 19 | /** 20 | * A branch DB is a hash from keys to sub-DBs. 21 | * @param Key type. K shall be String, byte array, Address, 22 | * Byte, Short, Integer, Long, Character or BigInteger. 23 | * @param Value type. V shall be VarDB, DictDB, ArrayDB or BranchDB. 24 | */ 25 | public interface BranchDB { 26 | /** 27 | * Returns sub-DB for the key. 28 | * 29 | * @param key key for sub-DB. 30 | * @return sub-DB. 31 | */ 32 | V at(K key); 33 | } 34 | -------------------------------------------------------------------------------- /javaee/api/src/java/score/ByteArrayObjectWriter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 ICON Foundation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package score; 18 | 19 | public interface ByteArrayObjectWriter extends ObjectWriter { 20 | byte[] toByteArray(); 21 | } 22 | -------------------------------------------------------------------------------- /javaee/app/allowlist/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'application' 2 | 3 | dependencies { 4 | implementation project(':rt') 5 | } 6 | 7 | application { 8 | mainClassName = 'JCLAllowlistPrinter' 9 | } 10 | -------------------------------------------------------------------------------- /javaee/app/dappcomp/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'application' 2 | 3 | dependencies { 4 | implementation 'org.slf4j:slf4j-api:1.7.26' 5 | implementation project(':tooling') 6 | implementation project(':rt') 7 | 8 | runtimeOnly 'org.slf4j:slf4j-simple:1.7.26' 9 | } 10 | 11 | application { 12 | mainClassName = 'DAppCompiler' 13 | } 14 | -------------------------------------------------------------------------------- /javaee/app/proxytest/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'application' 2 | 3 | dependencies { 4 | implementation 'org.slf4j:slf4j-api:1.7.26' 5 | implementation project(':exec') 6 | implementation project(':rt') 7 | 8 | runtimeOnly 'org.slf4j:slf4j-simple:1.7.26' 9 | } 10 | 11 | application { 12 | mainClassName = 'ProxyTest' 13 | applicationDefaultJvmArgs = [ 14 | '-Djava.library.path=' + project(':exec').buildDir + '/native', 15 | '-Dorg.slf4j.simpleLogger.defaultLogLevel=DEBUG' 16 | ] 17 | } 18 | -------------------------------------------------------------------------------- /javaee/exec/build.gradle: -------------------------------------------------------------------------------- 1 | dependencies { 2 | implementation project(':api') 3 | implementation project(':rt') 4 | implementation project(':tooling') 5 | 6 | implementation 'org.msgpack:msgpack-core:0.8.17' 7 | implementation 'org.slf4j:slf4j-api:1.7.26' 8 | 9 | testCompile( 10 | 'org.junit.jupiter:junit-jupiter-api:5.9.0', 11 | 'org.ow2.asm:asm:7.3.1', 12 | 'org.ow2.asm:asm-util:7.3.1' 13 | ) 14 | 15 | testImplementation( 16 | 'org.junit.jupiter:junit-jupiter-engine:5.9.0', 17 | project(':samples'), 18 | project(':logger'), 19 | files(project(':rt').sourceSets.test.output), 20 | ) 21 | } 22 | 23 | task compileNative(type: Exec) { 24 | workingDir 'src/native' 25 | commandLine 'make' 26 | } 27 | 28 | def outputNative = "$buildDir/native" 29 | if (file(outputNative).exists()) { 30 | compileNative.enabled = false 31 | } 32 | 33 | sourceSets { 34 | main { 35 | output.dir(outputNative, builtBy: 'compileNative') 36 | } 37 | } 38 | 39 | compileTestJava { 40 | options.compilerArgs += ['-parameters'] 41 | } 42 | 43 | test { 44 | useJUnitPlatform() 45 | maxHeapSize = "2048m" 46 | } 47 | -------------------------------------------------------------------------------- /javaee/exec/src/java/foundation/icon/ee/ipc/Connection.java: -------------------------------------------------------------------------------- 1 | package foundation.icon.ee.ipc; 2 | 3 | import java.io.IOException; 4 | import java.io.InputStream; 5 | 6 | public interface Connection { 7 | InputStream getInputStream(); 8 | void close() throws IOException; 9 | void send(byte[] data) throws IOException; 10 | } 11 | -------------------------------------------------------------------------------- /javaee/exec/src/java/foundation/icon/ee/ipc/Connector.java: -------------------------------------------------------------------------------- 1 | package foundation.icon.ee.ipc; 2 | 3 | import java.io.IOException; 4 | 5 | public interface Connector { 6 | Connection connect(String addr) throws IOException; 7 | } 8 | -------------------------------------------------------------------------------- /javaee/exec/src/java/foundation/icon/ee/score/FileIO.java: -------------------------------------------------------------------------------- 1 | package foundation.icon.ee.score; 2 | 3 | import java.io.IOException; 4 | 5 | public interface FileIO { 6 | byte[] readFile(String path) throws IOException; 7 | void writeFile(String path, byte[] bytes) throws IOException; 8 | } 9 | -------------------------------------------------------------------------------- /javaee/exec/test/java/foundation/icon/ee/BLSTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 ICON Foundation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package foundation.icon.ee; 18 | 19 | import foundation.icon.ee.test.SimpleTest; 20 | import org.junit.jupiter.api.Assertions; 21 | import org.junit.jupiter.api.Test; 22 | import testcases.BLSTestScore; 23 | 24 | public class BLSTest extends SimpleTest { 25 | @Test 26 | public void run() { 27 | var c = sm.mustDeploy(BLSTestScore.class); 28 | Assertions.assertEquals(0, c.invoke("test").getStatus()); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /javaee/exec/test/java/foundation/icon/ee/CodecTest2.java: -------------------------------------------------------------------------------- 1 | package foundation.icon.ee; 2 | 3 | import foundation.icon.ee.test.SimpleTest; 4 | import org.junit.jupiter.api.Test; 5 | 6 | public class CodecTest2 extends SimpleTest { 7 | @Test 8 | public void testMultipleDeploy() { 9 | final int N = 10; 10 | for (int i=0; i[]{CodecTest.Score.class, CodecTest.User.class}); 12 | score2.invoke("run"); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /javaee/exec/test/java/foundation/icon/ee/ReenterTest.java: -------------------------------------------------------------------------------- 1 | package foundation.icon.ee; 2 | 3 | import foundation.icon.ee.test.GoldenTest; 4 | import org.junit.jupiter.api.Test; 5 | import score.Address; 6 | import score.Context; 7 | import score.annotation.External; 8 | 9 | public class ReenterTest extends GoldenTest { 10 | public static class Score { 11 | private static final int MAX_COUNTER = 3; 12 | private int counter = 0; 13 | private Address self; 14 | 15 | public Score() { 16 | self = Context.getAddress(); 17 | } 18 | 19 | @External 20 | public void reenter() { 21 | Context.println("counter=" + counter); 22 | if (counter < MAX_COUNTER) { 23 | counter++; 24 | Context.call(self, "reenter"); 25 | } 26 | } 27 | } 28 | 29 | @Test 30 | public void test() { 31 | var score = sm.mustDeploy(Score.class); 32 | score.invoke("reenter"); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /javaee/exec/test/java/foundation/icon/ee/test/Frame.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 ICON Foundation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package foundation.icon.ee.test; 18 | 19 | import foundation.icon.ee.types.Address; 20 | 21 | public interface Frame { 22 | State getState(); 23 | void setState(State state); 24 | Account getAccount(); 25 | Contract getContract(); 26 | byte[] getContractID(); 27 | Address getAddress(); 28 | } 29 | -------------------------------------------------------------------------------- /javaee/exec/test/java/foundation/icon/ee/test/Indexer.java: -------------------------------------------------------------------------------- 1 | package foundation.icon.ee.test; 2 | 3 | import foundation.icon.ee.types.Address; 4 | 5 | public interface Indexer { 6 | int getIndex(Address addr); 7 | } 8 | -------------------------------------------------------------------------------- /javaee/exec/test/java/foundation/icon/ee/test/TeeOutputStream.java: -------------------------------------------------------------------------------- 1 | package foundation.icon.ee.test; 2 | 3 | import java.io.IOException; 4 | import java.io.OutputStream; 5 | 6 | public class TeeOutputStream extends OutputStream { 7 | private final OutputStream o1, o2; 8 | 9 | public TeeOutputStream(OutputStream o1, OutputStream o2) { 10 | this.o1 = o1; 11 | this.o2 = o2; 12 | } 13 | 14 | public void write(int b) throws IOException { 15 | o1.write(b); 16 | o2.write(b); 17 | } 18 | 19 | public void write(byte[] b) throws IOException { 20 | o1.write(b); 21 | o2.write(b); 22 | } 23 | 24 | public void write(byte[] b, int off, int len) throws IOException { 25 | o1.write(b, off, len); 26 | o2.write(b, off, len); 27 | } 28 | 29 | public void flush() throws IOException { 30 | o1.flush(); 31 | o2.flush(); 32 | } 33 | 34 | public void close() throws IOException { 35 | try { 36 | o1.close(); 37 | } finally { 38 | o2.close(); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /javaee/exec/test/java/foundation/icon/ee/test/TransactionException.java: -------------------------------------------------------------------------------- 1 | package foundation.icon.ee.test; 2 | 3 | import foundation.icon.ee.types.Result; 4 | 5 | public class TransactionException extends RuntimeException { 6 | private final Result result; 7 | 8 | public TransactionException(Result result) { 9 | this.result = result; 10 | } 11 | 12 | public TransactionException(String message, Result result) { 13 | super(message); 14 | this.result = result; 15 | } 16 | 17 | public TransactionException(String message, Throwable cause, Result result) { 18 | super(message, cause); 19 | this.result = result; 20 | } 21 | 22 | public TransactionException(Throwable cause, Result result) { 23 | super(cause); 24 | this.result = result; 25 | } 26 | 27 | public Result getResult() { 28 | return result; 29 | } 30 | 31 | public String toString() { 32 | return String.format("TransactionException{result:{%s}}", result); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /javaee/exec/test/resources/foundation/icon/ee/StructTest-packagePrivateStruct.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icon-project/goloop/67f6ff8433cef57fb9785e6065f0c94b8c1a86dd/javaee/exec/test/resources/foundation/icon/ee/StructTest-packagePrivateStruct.jar -------------------------------------------------------------------------------- /javaee/exec/test/resources/foundation/icon/ee/constant-dynamic.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icon-project/goloop/67f6ff8433cef57fb9785e6065f0c94b8c1a86dd/javaee/exec/test/resources/foundation/icon/ee/constant-dynamic.jar -------------------------------------------------------------------------------- /javaee/exec/test/resources/out/foundation/icon/ee/CompilerTest-testMultipleInits.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icon-project/goloop/67f6ff8433cef57fb9785e6065f0c94b8c1a86dd/javaee/exec/test/resources/out/foundation/icon/ee/CompilerTest-testMultipleInits.txt -------------------------------------------------------------------------------- /javaee/exec/test/resources/out/foundation/icon/ee/CompilerTest-testMultipleSameNames.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icon-project/goloop/67f6ff8433cef57fb9785e6065f0c94b8c1a86dd/javaee/exec/test/resources/out/foundation/icon/ee/CompilerTest-testMultipleSameNames.txt -------------------------------------------------------------------------------- /javaee/exec/test/resources/out/foundation/icon/ee/CompilerTest-testNoInit.txt: -------------------------------------------------------------------------------- 1 | Method{type=0, name='', flags=0, indexed=0, inputs=[], output=0, outputDescriptor=V} 2 | SEND getAPI 89b60d... 3 | RECV getAPI status=0 methods=[ 4 | Method{type=0, name='', flags=0, indexed=0, inputs=[], output=0} 5 | ] 6 | SEND invoke code=89b60d... flag=0 from=000001... to=010001... value=0 stepLimit=1000000000 method= params=[] CID=1 EID=1 codeState= 7 | RECV setObjGraph flag=1 next=2 hash=9d2ef70ebfaff999601736793750099d0c00b8c9211acec9ec3b890736d0a613 graphLen=58 graph=\x03\x00\x00\x00\x000foundation.icon.ee.CompilerTest$ScoreWithoutInit\x00\x00\x00\x01 8 | RECV result status=0 stepUsed=38609 ret= 9 | -------------------------------------------------------------------------------- /javaee/exec/test/resources/out/foundation/icon/ee/CompilerTest-testParamType.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icon-project/goloop/67f6ff8433cef57fb9785e6065f0c94b8c1a86dd/javaee/exec/test/resources/out/foundation/icon/ee/CompilerTest-testParamType.txt -------------------------------------------------------------------------------- /javaee/exec/test/resources/out/foundation/icon/ee/CompilerTest-testReturnType.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icon-project/goloop/67f6ff8433cef57fb9785e6065f0c94b8c1a86dd/javaee/exec/test/resources/out/foundation/icon/ee/CompilerTest-testReturnType.txt -------------------------------------------------------------------------------- /javaee/exec/test/resources/out/foundation/icon/ee/tooling/BasicOptimizerTest-simple.txt: -------------------------------------------------------------------------------- 1 | foundation/icon/ee/tooling/BasicOptimizerTest$Simple -> A$B 2 | 3 | Method{type=0, name='', flags=0, indexed=0, inputs=[], output=0, outputDescriptor=V} 4 | Method{type=0, name='external1', flags=2, indexed=0, inputs=[], output=0, outputDescriptor=V} 5 | 6 | // class version 55.0 (55) 7 | // access flags 0x21 8 | public class A$B { 9 | 10 | // compiled from: BasicOptimizerTest.java 11 | 12 | // access flags 0x1 13 | public ()V 14 | ALOAD 0 15 | INVOKESPECIAL java/lang/Object. ()V 16 | RETURN 17 | MAXSTACK = 1 18 | MAXLOCALS = 1 19 | 20 | // access flags 0x1 21 | public external1()V 22 | RETURN 23 | MAXSTACK = 0 24 | MAXLOCALS = 1 25 | } 26 | -------------------------------------------------------------------------------- /javaee/gradle.properties: -------------------------------------------------------------------------------- 1 | GROUP=foundation.icon 2 | VERSION=0.9.6 3 | -------------------------------------------------------------------------------- /javaee/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icon-project/goloop/67f6ff8433cef57fb9785e6065f0c94b8c1a86dd/javaee/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /javaee/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Fri Aug 30 14:06:32 KST 2019 2 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.5.1-all.zip 3 | distributionBase=GRADLE_USER_HOME 4 | distributionPath=wrapper/dists 5 | zipStorePath=wrapper/dists 6 | zipStoreBase=GRADLE_USER_HOME 7 | -------------------------------------------------------------------------------- /javaee/logger/build.gradle: -------------------------------------------------------------------------------- 1 | dependencies { 2 | implementation 'org.slf4j:slf4j-api:1.7.26' 3 | implementation project(':exec') 4 | } 5 | -------------------------------------------------------------------------------- /javaee/rt/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'java-library' 2 | 3 | dependencies { 4 | implementation project(':api') 5 | 6 | implementation 'org.bouncycastle:bcprov-jdk18on:1.78.1' 7 | implementation 'org.msgpack:msgpack-core:0.8.17' 8 | implementation 'org.slf4j:slf4j-api:1.7.26' 9 | implementation 'org.ow2.asm:asm:7.3.1' 10 | implementation 'org.ow2.asm:asm-commons:7.3.1' 11 | implementation 'org.ow2.asm:asm-util:7.3.1' 12 | implementation 'foundation.icon:blst-java:0.3.2' 13 | 14 | testImplementation( 15 | 'junit:junit:4.13.2', 16 | 'org.junit.jupiter:junit-jupiter-api:5.9.0' 17 | ) 18 | testRuntime( 19 | 'org.junit.jupiter:junit-jupiter-engine:5.9.0', 20 | 'org.junit.vintage:junit-vintage-engine:5.9.0' 21 | ) 22 | } 23 | 24 | test { 25 | useJUnitPlatform() 26 | } 27 | -------------------------------------------------------------------------------- /javaee/rt/src/java/a/ArrayElement.java: -------------------------------------------------------------------------------- 1 | package a; 2 | 3 | public enum ArrayElement { 4 | 5 | // Integral type 6 | BYTE(1), 7 | SHORT(2), 8 | INT(4), 9 | LONG(8), 10 | CHAR(2), 11 | 12 | // Floating-point type 13 | FLOAT(4), 14 | DOUBLE(8), 15 | 16 | // Reference type 17 | REF(8); 18 | 19 | static final int COST_PER_BYTE = 3; 20 | 21 | private final int energy; 22 | 23 | ArrayElement(int size) { 24 | this.energy = size * COST_PER_BYTE; 25 | } 26 | 27 | public int getEnergy() { 28 | return energy; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /javaee/rt/src/java/a/IArray.java: -------------------------------------------------------------------------------- 1 | package a; 2 | 3 | import i.IObject; 4 | 5 | public interface IArray extends IObject { 6 | 7 | public int length(); 8 | 9 | } 10 | -------------------------------------------------------------------------------- /javaee/rt/src/java/foundation/icon/ee/Agent.java: -------------------------------------------------------------------------------- 1 | package foundation.icon.ee; 2 | 3 | public interface Agent { 4 | ThreadLocal agent = new ThreadLocal<>(); 5 | 6 | static Agent get() { 7 | return agent.get(); 8 | } 9 | 10 | boolean isClassMeteringEnabled(); 11 | } 12 | -------------------------------------------------------------------------------- /javaee/rt/src/java/foundation/icon/ee/io/DataReader.java: -------------------------------------------------------------------------------- 1 | package foundation.icon.ee.io; 2 | 3 | import java.math.BigInteger; 4 | 5 | public interface DataReader { 6 | boolean readBoolean(); 7 | byte readByte(); 8 | short readShort(); 9 | char readChar(); 10 | int readInt(); 11 | float readFloat(); 12 | long readLong(); 13 | double readDouble(); 14 | BigInteger readBigInteger(); 15 | String readString(); 16 | byte[] readByteArray(); 17 | boolean readNullity(); 18 | void skip(int count); 19 | 20 | void readListHeader(); 21 | void readMapHeader(); 22 | boolean hasNext(); 23 | void readFooter(); 24 | long getTotalReadBytes(); 25 | } 26 | -------------------------------------------------------------------------------- /javaee/rt/src/java/foundation/icon/ee/io/DataWriter.java: -------------------------------------------------------------------------------- 1 | package foundation.icon.ee.io; 2 | 3 | import java.math.BigInteger; 4 | 5 | public interface DataWriter { 6 | void write(boolean v); 7 | void write(byte v); 8 | void write(short v); 9 | void write(char v); 10 | void write(int v); 11 | void write(float v); 12 | void write(long v); 13 | void write(double v); 14 | void write(BigInteger v); 15 | void write(String v); 16 | void write(byte[] v); 17 | void writeNullity(boolean nullity); 18 | 19 | void writeListHeader(int l); 20 | void writeMapHeader(int l); 21 | void writeFooter(); 22 | 23 | void flush(); 24 | byte[] toByteArray(); 25 | long getTotalWrittenBytes(); 26 | } 27 | -------------------------------------------------------------------------------- /javaee/rt/src/java/foundation/icon/ee/io/RLPNDataWriter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 ICON Foundation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package foundation.icon.ee.io; 18 | 19 | import java.math.BigInteger; 20 | 21 | public class RLPNDataWriter extends AbstractRLPDataWriter implements DataWriter { 22 | 23 | @Override 24 | protected byte[] toByteArray(BigInteger bi) { 25 | return bi.toByteArray(); 26 | } 27 | 28 | @Override 29 | protected void writeNullity(ByteArrayBuilder os, boolean nullity) { 30 | if (nullity) { 31 | os.write(0xf8); 32 | os.write(0x00); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /javaee/rt/src/java/foundation/icon/ee/struct/ReadableMethodProperty.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 ICON Foundation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package foundation.icon.ee.struct; 18 | 19 | import java.lang.reflect.InvocationTargetException; 20 | import java.lang.reflect.Method; 21 | 22 | public class ReadableMethodProperty extends MethodProperty implements ReadableProperty { 23 | public ReadableMethodProperty(Method method) { 24 | super(method); 25 | } 26 | 27 | public Object get(Object obj) throws InvocationTargetException, IllegalAccessException { 28 | return method.invoke(obj); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /javaee/rt/src/java/foundation/icon/ee/struct/ReadableProperty.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 ICON Foundation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package foundation.icon.ee.struct; 18 | 19 | import java.lang.reflect.InvocationTargetException; 20 | 21 | public interface ReadableProperty extends Property { 22 | Object get(Object obj) throws InvocationTargetException, IllegalAccessException; 23 | } 24 | -------------------------------------------------------------------------------- /javaee/rt/src/java/foundation/icon/ee/struct/WritableProperty.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 ICON Foundation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package foundation.icon.ee.struct; 18 | 19 | import java.lang.reflect.InvocationTargetException; 20 | 21 | public interface WritableProperty extends Property { 22 | void set(Object obj, Object value) throws InvocationTargetException; 23 | } 24 | -------------------------------------------------------------------------------- /javaee/rt/src/java/foundation/icon/ee/types/Bytes.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 ICON Foundation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package foundation.icon.ee.types; 18 | 19 | import org.bouncycastle.util.encoders.Hex; 20 | 21 | public class Bytes { 22 | public static String toHexString(byte[] to) { 23 | if (to != null) { 24 | return Hex.toHexString(to); 25 | } 26 | return "null"; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /javaee/rt/src/java/foundation/icon/ee/types/IllegalFormatException.java: -------------------------------------------------------------------------------- 1 | package foundation.icon.ee.types; 2 | 3 | public class IllegalFormatException extends PredefinedException { 4 | public IllegalFormatException() { 5 | this(Status.getMessage(Status.IllegalFormat)); 6 | } 7 | 8 | public IllegalFormatException(String message) { 9 | super(message); 10 | } 11 | 12 | public IllegalFormatException(String message, Throwable cause) { 13 | super(message, cause); 14 | } 15 | 16 | public IllegalFormatException(Throwable cause) { 17 | this(Status.getMessage(Status.IllegalFormat), cause); 18 | } 19 | 20 | public int getCode() { 21 | return Status.IllegalFormat; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /javaee/rt/src/java/foundation/icon/ee/types/ManualRevertException.java: -------------------------------------------------------------------------------- 1 | package foundation.icon.ee.types; 2 | 3 | import i.AvmException; 4 | 5 | public class ManualRevertException extends AvmException { 6 | private final int code; 7 | 8 | public ManualRevertException(int code) { 9 | super(); 10 | this.code = code; 11 | } 12 | 13 | public ManualRevertException(int code, String message) { 14 | super(message); 15 | this.code = code; 16 | } 17 | 18 | public ManualRevertException(int code, Throwable cause) { 19 | super(cause); 20 | this.code = code; 21 | } 22 | 23 | public ManualRevertException(int code, String message, Throwable cause) { 24 | super(message, cause); 25 | this.code = code; 26 | } 27 | 28 | public int getCode() { 29 | return code; 30 | } 31 | 32 | public String getResultMessage() { 33 | var m = getMessage(); 34 | return m != null ? m : Status.getMessage(getCode()); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /javaee/rt/src/java/foundation/icon/ee/types/UnknownFailureException.java: -------------------------------------------------------------------------------- 1 | package foundation.icon.ee.types; 2 | 3 | public class UnknownFailureException extends PredefinedException { 4 | public UnknownFailureException() { 5 | super(); 6 | } 7 | 8 | public UnknownFailureException(String message) { 9 | super(message); 10 | } 11 | 12 | public UnknownFailureException(String message, Throwable cause) { 13 | super(message, cause); 14 | } 15 | 16 | public UnknownFailureException(Throwable cause) { 17 | super(cause); 18 | } 19 | 20 | public int getCode() { 21 | return Status.UnknownFailure; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /javaee/rt/src/java/foundation/icon/ee/util/ASM.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 ICON Foundation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package foundation.icon.ee.util; 18 | 19 | import org.objectweb.asm.ClassReader; 20 | import org.objectweb.asm.ClassVisitor; 21 | 22 | public class ASM { 23 | public static T accept(byte[] classBytes, T cv) { 24 | var cr = new ClassReader(classBytes); 25 | cr.accept(cv, 0); 26 | return cv; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /javaee/rt/src/java/foundation/icon/ee/util/Disposable.java: -------------------------------------------------------------------------------- 1 | package foundation.icon.ee.util; 2 | 3 | public interface Disposable { 4 | void dispose(); 5 | } 6 | -------------------------------------------------------------------------------- /javaee/rt/src/java/foundation/icon/ee/util/LogMarker.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 ICON Foundation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package foundation.icon.ee.util; 18 | 19 | import org.slf4j.Marker; 20 | import org.slf4j.MarkerFactory; 21 | 22 | public class LogMarker { 23 | public static String TRACE = "TRACE"; 24 | 25 | public static Marker Trace = MarkerFactory.getMarker(TRACE); 26 | } 27 | -------------------------------------------------------------------------------- /javaee/rt/src/java/i/AvmError.java: -------------------------------------------------------------------------------- 1 | package i; 2 | 3 | 4 | /** 5 | * This is a specific sub-tree of the {#link InternalError} hierarchy, specifically designed to describe 6 | * a node-level failure. That is, these cases are so severe that we are expecting not even fail the 7 | * contract code, but drop it and bring the system down. 8 | * These cases are so severe that calling "System.exit()" open wanting to instantiate one would be a 9 | * reasonable implementation. 10 | */ 11 | public abstract class AvmError extends AvmThrowable { 12 | private static final long serialVersionUID = 1L; 13 | 14 | protected AvmError() { 15 | super(); 16 | } 17 | 18 | protected AvmError(String message) { 19 | super(message); 20 | } 21 | 22 | protected AvmError(String message, Throwable cause) { 23 | super(message, cause); 24 | } 25 | 26 | protected AvmError(Throwable cause) { 27 | super(cause); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /javaee/rt/src/java/i/AvmException.java: -------------------------------------------------------------------------------- 1 | package i; 2 | 3 | 4 | /** 5 | * Indicates an internal runtime unexpected condition, especially for AVM execution rule violation. 6 | * 7 | * Note: This class extends {@link RuntimeException} since they are not expected to be caught, but to unwind the 8 | * stack. This means that we are expecting to force our way out of the user code, as quickly as possible, and 9 | * catch this only at the top-level entry-point we control. 10 | * Depending on the severity of the problem, this either implies a failure of the contract or a failure of the 11 | * node where we are trying to run. 12 | */ 13 | public abstract class AvmException extends AvmThrowable { 14 | private static final long serialVersionUID = 1L; 15 | 16 | protected AvmException() { 17 | super(); 18 | } 19 | 20 | protected AvmException(String message) { 21 | super(message); 22 | } 23 | 24 | protected AvmException(String message, Throwable cause) { 25 | super(message, cause); 26 | } 27 | 28 | protected AvmException(Throwable cause) { 29 | super(cause); 30 | } 31 | 32 | public abstract int getCode(); 33 | 34 | public abstract String getResultMessage(); 35 | } 36 | -------------------------------------------------------------------------------- /javaee/rt/src/java/i/AvmThrowable.java: -------------------------------------------------------------------------------- 1 | package i; 2 | 3 | /** 4 | * The root of the exception/error hierarchy in AVM. The DApp should not be able 5 | * to catch any of the exceptions or errors which extend from this class. 6 | */ 7 | public class AvmThrowable extends RuntimeException { 8 | private static final long serialVersionUID = 1L; 9 | 10 | protected AvmThrowable() { 11 | super(); 12 | } 13 | 14 | protected AvmThrowable(String message) { 15 | super(message); 16 | } 17 | 18 | protected AvmThrowable(String message, Throwable cause) { 19 | super(message, cause); 20 | } 21 | 22 | protected AvmThrowable(Throwable cause) { 23 | super(cause); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /javaee/rt/src/java/i/ConstantToken.java: -------------------------------------------------------------------------------- 1 | package i; 2 | 3 | public class ConstantToken { 4 | 5 | public final int constantId; 6 | 7 | public ConstantToken(int constantId) { 8 | this.constantId = constantId; 9 | } 10 | 11 | public static int getReadIndexFromConstantId(int constantId){ 12 | return (-1 * constantId) - 1; 13 | } 14 | 15 | public static int getConstantIdFromReadIndex(int readIndex){ 16 | return (-1 * readIndex) - 1; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /javaee/rt/src/java/i/ConstantsHolder.java: -------------------------------------------------------------------------------- 1 | package i; 2 | 3 | import s.java.lang.Object; 4 | 5 | import java.util.HashMap; 6 | import java.util.Map; 7 | 8 | public class ConstantsHolder { 9 | 10 | public static Map getConstants() { 11 | return constants; 12 | } 13 | 14 | private static Map constants = new HashMap<>(); 15 | 16 | public static void addConstant(int constantId, s.java.lang.Object constant) { 17 | RuntimeAssertionError.assertTrue(!constants.containsKey(constantId)); 18 | constants.put(constantId, constant); 19 | } 20 | 21 | 22 | } 23 | -------------------------------------------------------------------------------- /javaee/rt/src/java/i/FrameContext.java: -------------------------------------------------------------------------------- 1 | package i; 2 | 3 | import org.aion.avm.core.IExternalState; 4 | 5 | public interface FrameContext { 6 | IDBStorage getDBStorage(); 7 | IExternalState getExternalState(); 8 | boolean waitForRefund(); 9 | void limitPendingRefundLength(); 10 | void setStatusFlag(int rerun); 11 | int getStatusFlag(); 12 | boolean isDeployFrame(); 13 | } 14 | -------------------------------------------------------------------------------- /javaee/rt/src/java/i/FunctionFactory.java: -------------------------------------------------------------------------------- 1 | package i; 2 | 3 | import java.lang.invoke.MethodHandle; 4 | import java.lang.invoke.MethodHandles; 5 | 6 | import p.score.InternalFunction; 7 | 8 | 9 | public final class FunctionFactory { 10 | private final MethodHandles.Lookup lookup; 11 | private final MethodHandle target; 12 | 13 | public FunctionFactory(MethodHandles.Lookup lookup, MethodHandle target) { 14 | this.lookup = lookup; 15 | this.target = target; 16 | } 17 | 18 | public s.java.util.function.Function instantiate() { 19 | return InternalFunction.createFunction(this.lookup, this.target); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /javaee/rt/src/java/i/GenericPredefinedException.java: -------------------------------------------------------------------------------- 1 | package i; 2 | 3 | import foundation.icon.ee.types.PredefinedException; 4 | 5 | public class GenericPredefinedException extends PredefinedException { 6 | private int code; 7 | 8 | public GenericPredefinedException() { 9 | super(); 10 | } 11 | 12 | public GenericPredefinedException(int code) { 13 | super(); 14 | this.code = code; 15 | } 16 | 17 | public GenericPredefinedException(int code, String message) { 18 | super(message); 19 | this.code = code; 20 | } 21 | 22 | public GenericPredefinedException(int code, String message, Throwable cause) { 23 | super(message, cause); 24 | this.code = code; 25 | } 26 | 27 | public GenericPredefinedException(int code, Throwable cause) { 28 | super(cause); 29 | this.code = code; 30 | } 31 | 32 | public int getCode() { 33 | return code; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /javaee/rt/src/java/i/IDBStorage.java: -------------------------------------------------------------------------------- 1 | package i; 2 | 3 | public interface IDBStorage { 4 | void setBytes(byte[] key, byte[] value); 5 | byte[] getBytes(byte[] key); 6 | void setArrayLength(byte[] key, int l); 7 | int getArrayLength(byte[] key); 8 | void flush(); 9 | } 10 | -------------------------------------------------------------------------------- /javaee/rt/src/java/i/IInstrumentationFactory.java: -------------------------------------------------------------------------------- 1 | package i; 2 | 3 | 4 | /** 5 | * The abstract description of something which can generate IInstrumentation instances. 6 | * This is required since the AVM owns the actual threads it uses, meaning it needs to call out to create/destroy the IInstrumentation 7 | * instances it wants to attach to these threads. 8 | * Note that the interface is symmetric in case the implementation requires cleanup. The "destroy" call is made after the instance 9 | * has been detached from its thread. 10 | */ 11 | public interface IInstrumentationFactory { 12 | public IInstrumentation createInstrumentation(); 13 | public void destroyInstrumentation(IInstrumentation instance); 14 | } 15 | -------------------------------------------------------------------------------- /javaee/rt/src/java/i/IObject.java: -------------------------------------------------------------------------------- 1 | package i; 2 | 3 | import s.java.lang.Class; 4 | import s.java.lang.String; 5 | 6 | 7 | /** 8 | * See issue-80 for a more in-depth rationale leading up to the creation of this class. 9 | * In short, this defines the parts of the "shadow java.lang.Object" interface which is callable by contract code. 10 | * This exists as the root of both the class hierarchy and the interface hierarchy in order to allow interfaces to 11 | * be assignable to something we can treat as the "root". 12 | */ 13 | public interface IObject { 14 | public Class avm_getClass(); 15 | 16 | public int avm_hashCode(); 17 | 18 | public boolean avm_equals(IObject obj); 19 | 20 | public String avm_toString(); 21 | } 22 | -------------------------------------------------------------------------------- /javaee/rt/src/java/i/IObjectArray.java: -------------------------------------------------------------------------------- 1 | package i; 2 | 3 | 4 | import a.IArray; 5 | 6 | /** 7 | * This interface contains the common ObjectArray methods callable from transformed code. 8 | * Originally, these calls were invokevirtual against the ObjectArray instance, directly, but some type unification rules around arrays and interfaces 9 | * required that we often use an interface and call against it using invokeinterface. This interface declares those requirements. 10 | * It also needs to extend IObject since even unifying array contexts need to ultimately unify to object. 11 | * See issue-82 for more details. 12 | */ 13 | public interface IObjectArray extends IObject, IArray { 14 | public Object get(int idx); 15 | 16 | public void set(int idx, Object val); 17 | 18 | public IObject avm_clone(); 19 | } 20 | -------------------------------------------------------------------------------- /javaee/rt/src/java/i/IObjectDeserializer.java: -------------------------------------------------------------------------------- 1 | package i; 2 | 3 | 4 | /** 5 | * Passed to deserializeSelf() so that the receiver can abstractly deserialize itself. 6 | * Note that there is no identification of data elements, other than the order they are read. 7 | */ 8 | public interface IObjectDeserializer { 9 | boolean readBoolean(); 10 | byte readByte(); 11 | short readShort(); 12 | char readChar(); 13 | int readInt(); 14 | float readFloat(); 15 | long readLong(); 16 | double readDouble(); 17 | void readByteArray(byte[] result); 18 | Object readObject(); 19 | String readClassName(); 20 | void automaticallyDeserializeFromRoot(Class rootClass, Object instance); 21 | } 22 | -------------------------------------------------------------------------------- /javaee/rt/src/java/i/IObjectSerializer.java: -------------------------------------------------------------------------------- 1 | package i; 2 | 3 | 4 | /** 5 | * Passed to serializeSelf() so that the receiver can abstractly serialize itself. 6 | * Note that there is no identification of data elements, other than the order they are written. 7 | */ 8 | public interface IObjectSerializer { 9 | void writeBoolean(boolean value); 10 | void writeByte(byte value); 11 | void writeShort(short value); 12 | void writeChar(char value); 13 | void writeInt(int value); 14 | void writeFloat(float value); 15 | void writeLong(long value); 16 | void writeDouble(double value); 17 | void writeByteArray(byte[] value); 18 | void writeObject(Object value); 19 | void writeClassName(String internalClassName); 20 | void automaticallySerializeToRoot(Class rootClass, Object instance); 21 | } 22 | -------------------------------------------------------------------------------- /javaee/rt/src/java/i/IRuntimeSetup.java: -------------------------------------------------------------------------------- 1 | package i; 2 | 3 | 4 | /** 5 | * This just exists to make it easier to call into the Helper class when mapped into the user class loader (as "H"). 6 | * This means we just ask it for an instance, and we can use that for setup/teardown of its state, instead of carrying 7 | * around a lot of logic related to reflection. 8 | */ 9 | public interface IRuntimeSetup { 10 | public void attach(IInstrumentation instrumentation); 11 | public void detach(IInstrumentation instrumentation); 12 | } 13 | -------------------------------------------------------------------------------- /javaee/rt/src/java/i/JvmError.java: -------------------------------------------------------------------------------- 1 | package i; 2 | 3 | 4 | /** 5 | * Handles the cases of some kind of asynchronous JVM-originating exception which nobody should try to handle. 6 | */ 7 | public class JvmError extends AvmError { 8 | private static final long serialVersionUID = 1L; 9 | 10 | public JvmError(VirtualMachineError error) { 11 | super(error); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /javaee/rt/src/java/i/OutOfEnergyException.java: -------------------------------------------------------------------------------- 1 | package i; 2 | 3 | import foundation.icon.ee.types.Status; 4 | import foundation.icon.ee.types.PredefinedException; 5 | 6 | /** 7 | * Error that indicates the DApp runs out of energy. 8 | */ 9 | public class OutOfEnergyException extends PredefinedException { 10 | private static final long serialVersionUID = 1L; 11 | 12 | public int getCode() { 13 | return Status.OutOfStep; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /javaee/rt/src/java/i/OutOfStackException.java: -------------------------------------------------------------------------------- 1 | package i; 2 | 3 | import foundation.icon.ee.types.Status; 4 | import foundation.icon.ee.types.PredefinedException; 5 | 6 | /** 7 | * Error that indicates the DApp runs out of stack. 8 | */ 9 | public class OutOfStackException extends PredefinedException { 10 | private static final long serialVersionUID = 1L; 11 | 12 | public int getCode() { 13 | return Status.StackOverflow; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /javaee/rt/src/java/i/RunnableFactory.java: -------------------------------------------------------------------------------- 1 | package i; 2 | 3 | import java.lang.invoke.MethodHandle; 4 | import java.lang.invoke.MethodHandles; 5 | 6 | import p.score.InternalRunnable; 7 | 8 | 9 | public final class RunnableFactory { 10 | private final MethodHandles.Lookup lookup; 11 | private final MethodHandle target; 12 | 13 | public RunnableFactory(MethodHandles.Lookup lookup, MethodHandle target) { 14 | this.lookup = lookup; 15 | this.target = target; 16 | } 17 | 18 | public s.java.lang.Runnable instantiate() { 19 | return InternalRunnable.createRunnable(this.lookup, this.target); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /javaee/rt/src/java/i/UncaughtException.java: -------------------------------------------------------------------------------- 1 | package i; 2 | 3 | import foundation.icon.ee.types.Status; 4 | import foundation.icon.ee.types.PredefinedException; 5 | 6 | /** 7 | * Represent an exception which is generated by user's code but propagates to the AVM. 8 | */ 9 | public class UncaughtException extends PredefinedException { 10 | private static final long serialVersionUID = 1L; 11 | 12 | public UncaughtException(Throwable thrownByVmInUserSpace) { 13 | super(thrownByVmInUserSpace); 14 | } 15 | 16 | public UncaughtException(String messageThrownByUser, Throwable throwableWrapper) { 17 | // We have no good way to communicate this within the standard exception hierarchy so just pass the message. 18 | super(messageThrownByUser, throwableWrapper); 19 | } 20 | 21 | public int getCode() { 22 | return Status.UnknownFailure; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /javaee/rt/src/java/org/aion/avm/NameStyle.java: -------------------------------------------------------------------------------- 1 | package org.aion.avm; 2 | 3 | /** 4 | * Specifies a naming convention or style. 5 | */ 6 | public enum NameStyle { 7 | 8 | DOT_NAME, // Example: java.lang.Object 9 | SLASH_NAME, // Example: java/lang/Object 10 | ; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /javaee/rt/src/java/org/aion/avm/StorageFees.java: -------------------------------------------------------------------------------- 1 | package org.aion.avm; 2 | 3 | /** 4 | * A few constants to describe how we limit and bill for storage graph serialization/deserialization. 5 | */ 6 | public class StorageFees { 7 | public static final int MAX_GRAPH_SIZE = 500_000; 8 | public static final int READ_PRICE_PER_BYTE = 1; 9 | public static final int WRITE_PRICE_PER_BYTE = 3; 10 | } 11 | -------------------------------------------------------------------------------- /javaee/rt/src/java/org/aion/avm/core/persistence/IGlobalResolver.java: -------------------------------------------------------------------------------- 1 | package org.aion.avm.core.persistence; 2 | 3 | 4 | /** 5 | * Used by the persistence system when reading or writing object instances in order to handle constants and classes. 6 | * These are both concepts which must be translated between the global in-memory state of the system and the serialized 7 | * for since they live longer than the invocation, itself. 8 | */ 9 | public interface IGlobalResolver { 10 | String getAsInternalClassName(Object target); 11 | Object getClassObjectForInternalName(String internalClassName); 12 | 13 | int getAsConstant(Object target); 14 | Object getConstantForIdentifier(int constantIdentifier); 15 | } 16 | -------------------------------------------------------------------------------- /javaee/rt/src/java/org/aion/avm/core/persistence/IPersistenceNameMapper.java: -------------------------------------------------------------------------------- 1 | package org.aion.avm.core.persistence; 2 | 3 | 4 | /** 5 | * Used by the persistence system to translate class names between the ones in the storage system and our internal names 6 | * which are specific to our implementation. 7 | */ 8 | public interface IPersistenceNameMapper { 9 | public String getStorageClassName(String ourName); 10 | 11 | public String getInternalClassName(String storageClassName); 12 | } 13 | -------------------------------------------------------------------------------- /javaee/rt/src/java/org/aion/avm/core/persistence/ReferenceConstants.java: -------------------------------------------------------------------------------- 1 | package org.aion.avm.core.persistence; 2 | 3 | 4 | /** 5 | * Constants used when describing inter-object references within the serialized form. 6 | */ 7 | public class ReferenceConstants { 8 | public static final byte REF_NULL = 0x0; 9 | public static final byte REF_CLASS = 0x1; 10 | public static final byte REF_CONSTANT = 0x2; 11 | public static final byte REF_NORMAL = 0x3; 12 | } 13 | -------------------------------------------------------------------------------- /javaee/rt/src/java/org/aion/avm/core/persistence/StandardNameMapper.java: -------------------------------------------------------------------------------- 1 | package org.aion.avm.core.persistence; 2 | 3 | import org.aion.avm.core.ClassRenamer; 4 | import org.aion.avm.core.ClassRenamer.ArrayType; 5 | 6 | public class StandardNameMapper implements IPersistenceNameMapper { 7 | private final ClassRenamer classRenamer; 8 | 9 | public StandardNameMapper(ClassRenamer classRenamer) { 10 | this.classRenamer = classRenamer; 11 | } 12 | 13 | @Override 14 | public String getStorageClassName(String ourName) { 15 | return this.classRenamer.toPreRename(ourName); 16 | } 17 | 18 | @Override 19 | public String getInternalClassName(String storageClassName) { 20 | return this.classRenamer.toPostRename(storageClassName, ArrayType.PRECISE_TYPE); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /javaee/rt/src/java/org/aion/avm/core/rejection/RejectionAnnotationVisitor.java: -------------------------------------------------------------------------------- 1 | package org.aion.avm.core.rejection; 2 | 3 | import org.objectweb.asm.AnnotationVisitor; 4 | import org.objectweb.asm.Opcodes; 5 | 6 | 7 | /** 8 | * Filters out annotations since we don't use them. 9 | */ 10 | public class RejectionAnnotationVisitor extends AnnotationVisitor { 11 | public RejectionAnnotationVisitor() { 12 | super(Opcodes.ASM7); 13 | } 14 | 15 | @Override 16 | public void visit(String name, Object value) { 17 | // Filter. 18 | } 19 | 20 | @Override 21 | public void visitEnum(String name, String descriptor, String value) { 22 | // Filter. 23 | } 24 | 25 | @Override 26 | public AnnotationVisitor visitAnnotation(String name, String descriptor) { 27 | // Filter with this, since we are stateless. 28 | return this; 29 | } 30 | 31 | @Override 32 | public AnnotationVisitor visitArray(String name) { 33 | // Filter with this, since we are stateless. 34 | return this; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /javaee/rt/src/java/org/aion/avm/core/rejection/RejectionFieldVisitor.java: -------------------------------------------------------------------------------- 1 | package org.aion.avm.core.rejection; 2 | 3 | import org.objectweb.asm.AnnotationVisitor; 4 | import org.objectweb.asm.Attribute; 5 | import org.objectweb.asm.FieldVisitor; 6 | import org.objectweb.asm.Opcodes; 7 | import org.objectweb.asm.TypePath; 8 | 9 | /** 10 | * Filters out annotations since we don't use them. 11 | */ 12 | public class RejectionFieldVisitor extends FieldVisitor { 13 | public RejectionFieldVisitor(FieldVisitor visitor) { 14 | super(Opcodes.ASM7, visitor); 15 | } 16 | 17 | @Override 18 | public AnnotationVisitor visitAnnotation(String descriptor, boolean visible) { 19 | // Filter this. 20 | return new RejectionAnnotationVisitor(); 21 | } 22 | 23 | @Override 24 | public AnnotationVisitor visitTypeAnnotation(int typeRef, TypePath typePath, String descriptor, boolean visible) { 25 | // Filter this. 26 | return new RejectionAnnotationVisitor(); 27 | } 28 | 29 | @Override 30 | public void visitAttribute(Attribute attribute) { 31 | // "Non-standard attributes" are not supported, so filter them. 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /javaee/rt/src/java/org/aion/avm/core/types/ClassInfo.java: -------------------------------------------------------------------------------- 1 | package org.aion.avm.core.types; 2 | 3 | public class ClassInfo { 4 | private boolean isInterface; 5 | private byte[] bytes; 6 | 7 | public ClassInfo(boolean isInterface, byte[] bytes) { 8 | this.isInterface = isInterface; 9 | this.bytes = bytes; 10 | } 11 | 12 | public boolean isInterface() { 13 | return isInterface; 14 | } 15 | 16 | public byte[] getBytes() { 17 | return bytes; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /javaee/rt/src/java/org/aion/avm/core/types/GeneratedClassConsumer.java: -------------------------------------------------------------------------------- 1 | package org.aion.avm.core.types; 2 | 3 | /** 4 | * An interface which exists to allow external concerns to be notified when a class is dynamically generated for the purposes of exception wrapping. 5 | */ 6 | public interface GeneratedClassConsumer { 7 | /** 8 | * Called when a new class is generated. 9 | * 10 | * @param superClassName The name of the super class (in slash form). 11 | * @param className The name of the generated class (in slash form). 12 | * @param bytecode The bytecode of the generated class. 13 | */ 14 | public void accept(String superClassName, String className, byte[] bytecode); 15 | } 16 | -------------------------------------------------------------------------------- /javaee/rt/src/java/org/aion/avm/core/types/Pair.java: -------------------------------------------------------------------------------- 1 | package org.aion.avm.core.types; 2 | 3 | import java.util.Objects; 4 | 5 | public class Pair { 6 | public K key; 7 | public V value; 8 | 9 | private Pair(K key, V value) { 10 | this.key = key; 11 | this.value = value; 12 | } 13 | 14 | public static Pair of(K key, V value) { 15 | return new Pair<>(key, value); 16 | } 17 | 18 | @Override 19 | public boolean equals(Object o) { 20 | if (this == o) { 21 | return true; 22 | } 23 | if (o == null || getClass() != o.getClass()) { 24 | return false; 25 | } 26 | Pair pair = (Pair) o; 27 | return key.equals(pair.key) && 28 | value.equals(pair.value); 29 | } 30 | 31 | @Override 32 | public int hashCode() { 33 | return Objects.hash(key, value); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /javaee/rt/src/java/org/aion/avm/core/util/ByteArrayWrapper.java: -------------------------------------------------------------------------------- 1 | package org.aion.avm.core.util; 2 | 3 | import java.util.Arrays; 4 | 5 | /** 6 | * A wrapper of byte[], to be used as the HashMap key. 7 | */ 8 | public final class ByteArrayWrapper 9 | { 10 | private final byte[] data; 11 | 12 | public ByteArrayWrapper(byte[] data) 13 | { 14 | if (data == null) 15 | { 16 | throw new NullPointerException(); 17 | } 18 | this.data = data; 19 | } 20 | 21 | @Override 22 | public boolean equals(Object object) 23 | { 24 | if (!(object instanceof ByteArrayWrapper)) 25 | { 26 | return false; 27 | } 28 | return Arrays.equals(data, ((ByteArrayWrapper)object).data); 29 | } 30 | 31 | @Override 32 | public int hashCode() 33 | { 34 | return Arrays.hashCode(data); 35 | } 36 | 37 | @Override 38 | public String toString() { 39 | return Helpers.bytesToHexString(data); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /javaee/rt/src/java/org/aion/avm/core/util/DebugNameResolver.java: -------------------------------------------------------------------------------- 1 | package org.aion.avm.core.util; 2 | 3 | import i.PackageConstants; 4 | 5 | public class DebugNameResolver { 6 | 7 | public static String getUserPackageSlashPrefix (String name, boolean preserveDebuggability){ 8 | return preserveDebuggability ? name : PackageConstants.kUserSlashPrefix + name; 9 | } 10 | 11 | public static String getUserPackageDotPrefix (String name, boolean preserveDebuggability){ 12 | return preserveDebuggability ? name : PackageConstants.kUserDotPrefix + name; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /javaee/rt/src/java/org/aion/avm/utilities/analyze/ByteReader.java: -------------------------------------------------------------------------------- 1 | package org.aion.avm.utilities.analyze; 2 | 3 | import java.nio.ByteBuffer; 4 | 5 | public class ByteReader { 6 | 7 | private ByteBuffer buffer; 8 | 9 | public ByteReader(byte[] bytes) { 10 | buffer = ByteBuffer.wrap(bytes); 11 | } 12 | 13 | // The types u1, u2, and u4 represent an unsigned one-, two-, or four-byte quantity, respectively 14 | // ByteBuffer is read in a big-endian byte order 15 | public byte readU1() { 16 | return buffer.get(); 17 | } 18 | 19 | public short readU2() { 20 | return buffer.getShort(); 21 | } 22 | 23 | public int readU4() { 24 | return buffer.getInt(); 25 | } 26 | 27 | public byte[] readNBytes(int n) { 28 | byte[] utf8 = new byte[n]; 29 | buffer.get(utf8); 30 | return utf8; 31 | } 32 | 33 | public int position() { 34 | return buffer.position(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /javaee/rt/src/java/p/score/AnyDB.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 ICON Foundation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package p.score; 18 | 19 | public interface AnyDB extends VarDB, BranchDB, DictDB, ArrayDB { 20 | } 21 | -------------------------------------------------------------------------------- /javaee/rt/src/java/p/score/ArrayDB.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 ICON Foundation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package p.score; 18 | 19 | import i.IObject; 20 | 21 | public interface ArrayDB { 22 | void avm_add(IObject value); 23 | void avm_set(int index, IObject value); 24 | void avm_removeLast(); 25 | IObject avm_get(int index); 26 | int avm_size(); 27 | IObject avm_pop(); 28 | } 29 | -------------------------------------------------------------------------------- /javaee/rt/src/java/p/score/BranchDB.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 ICON Foundation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package p.score; 18 | 19 | import i.IObject; 20 | 21 | public interface BranchDB { 22 | /** 23 | * Returns Collection for the key. This method shall be called only if 24 | * type of V is DictDB or ArrayDB. 25 | * 26 | * @param key 27 | * @return 28 | */ 29 | IObject avm_at(IObject key); 30 | } 31 | -------------------------------------------------------------------------------- /javaee/rt/src/java/p/score/ByteArrayObjectWriter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 ICON Foundation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package p.score; 18 | 19 | import a.ByteArray; 20 | 21 | public interface ByteArrayObjectWriter extends ObjectWriter { 22 | ByteArray avm_toByteArray(); 23 | } 24 | -------------------------------------------------------------------------------- /javaee/rt/src/java/p/score/DictDB.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 ICON Foundation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package p.score; 18 | 19 | import i.IObject; 20 | 21 | public interface DictDB { 22 | void avm_set(IObject key, IObject value); 23 | IObject avm_get(IObject key); 24 | IObject avm_getOrDefault(IObject key, IObject defaultValue); 25 | } 26 | -------------------------------------------------------------------------------- /javaee/rt/src/java/p/score/VarDB.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 ICON Foundation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package p.score; 18 | 19 | import i.IObject; 20 | 21 | public interface VarDB { 22 | void avm_set(IObject value); 23 | IObject avm_get(); 24 | IObject avm_getOrDefault(IObject defaultValue); 25 | } 26 | -------------------------------------------------------------------------------- /javaee/rt/src/java/s/java/io/Serializable.java: -------------------------------------------------------------------------------- 1 | package s.java.io; 2 | 3 | import i.IObject; 4 | 5 | public interface Serializable extends IObject { 6 | 7 | } 8 | -------------------------------------------------------------------------------- /javaee/rt/src/java/s/java/lang/Appendable.java: -------------------------------------------------------------------------------- 1 | package s.java.lang; 2 | 3 | import java.io.IOException; 4 | import i.IObject; 5 | 6 | public interface Appendable extends IObject { 7 | 8 | Appendable avm_append(CharSequence csq) throws IOException; 9 | 10 | Appendable avm_append(CharSequence csq, int start, int end) throws IOException; 11 | 12 | Appendable avm_append(char c) throws IOException; 13 | } 14 | -------------------------------------------------------------------------------- /javaee/rt/src/java/s/java/lang/CharSequence.java: -------------------------------------------------------------------------------- 1 | package s.java.lang; 2 | 3 | import i.IObject; 4 | 5 | public interface CharSequence extends IObject { 6 | 7 | int avm_length(); 8 | 9 | char avm_charAt(int index); 10 | 11 | CharSequence avm_subSequence(int start, int end); 12 | 13 | String avm_toString(); 14 | } -------------------------------------------------------------------------------- /javaee/rt/src/java/s/java/lang/Cloneable.java: -------------------------------------------------------------------------------- 1 | package s.java.lang; 2 | 3 | import i.IObject; 4 | 5 | public interface Cloneable extends IObject { 6 | } 7 | -------------------------------------------------------------------------------- /javaee/rt/src/java/s/java/lang/Comparable.java: -------------------------------------------------------------------------------- 1 | package s.java.lang; 2 | 3 | import i.IObject; 4 | 5 | public interface Comparable extends IObject { 6 | 7 | public int avm_compareTo(T o); 8 | } 9 | -------------------------------------------------------------------------------- /javaee/rt/src/java/s/java/lang/Error.java: -------------------------------------------------------------------------------- 1 | package s.java.lang; 2 | 3 | import i.IInstrumentation; 4 | 5 | 6 | /** 7 | * Our shadow implementation of java.lang.Error. 8 | * 9 | * This only exists as an intermediary since we needed to implement AssertionError. 10 | */ 11 | public class Error extends Throwable { 12 | static { 13 | // Shadow classes MUST be loaded during bootstrap phase. 14 | IInstrumentation.attachedThreadInstrumentation.get().bootstrapOnly(); 15 | } 16 | 17 | public Error() { 18 | super(); 19 | } 20 | 21 | public Error(String message) { 22 | super(message); 23 | } 24 | 25 | public Error(String message, Throwable cause) { 26 | super(message, cause); 27 | } 28 | 29 | public Error(Throwable cause) { 30 | super(cause); 31 | } 32 | 33 | // Deserializer support. 34 | public Error(java.lang.Void ignore, int readIndex) { 35 | super(ignore, readIndex); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /javaee/rt/src/java/s/java/lang/Exception.java: -------------------------------------------------------------------------------- 1 | package s.java.lang; 2 | 3 | import i.IInstrumentation; 4 | 5 | 6 | /** 7 | * Our shadow implementation of java.lang.Exception. 8 | * 9 | * This only exists as an intermediary since we needed to implement a few specific subclasses. 10 | */ 11 | public class Exception extends Throwable { 12 | static { 13 | // Shadow classes MUST be loaded during bootstrap phase. 14 | IInstrumentation.attachedThreadInstrumentation.get().bootstrapOnly(); 15 | } 16 | 17 | public Exception() { 18 | super(); 19 | } 20 | 21 | public Exception(String message) { 22 | super(message); 23 | } 24 | 25 | public Exception(String message, Throwable cause) { 26 | super(message, cause); 27 | } 28 | 29 | public Exception(Throwable cause) { 30 | super(cause); 31 | } 32 | 33 | // Deserializer support. 34 | public Exception(java.lang.Void ignore, int readIndex) { 35 | super(ignore, readIndex); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /javaee/rt/src/java/s/java/lang/Iterable.java: -------------------------------------------------------------------------------- 1 | package s.java.lang; 2 | 3 | import i.IObject; 4 | import s.java.util.Iterator; 5 | 6 | public interface Iterable extends IObject { 7 | Iterator avm_iterator(); 8 | 9 | //Default 10 | } 11 | -------------------------------------------------------------------------------- /javaee/rt/src/java/s/java/lang/Runnable.java: -------------------------------------------------------------------------------- 1 | package s.java.lang; 2 | 3 | import i.IObject; 4 | 5 | /** 6 | * @author Roman Katerinenko 7 | */ 8 | public interface Runnable extends IObject { 9 | void avm_run() throws e.s.java.lang.Throwable; 10 | } -------------------------------------------------------------------------------- /javaee/rt/src/java/s/java/lang/RuntimeException.java: -------------------------------------------------------------------------------- 1 | package s.java.lang; 2 | 3 | import i.IInstrumentation; 4 | 5 | 6 | /** 7 | * Our shadow implementation of java.lang.RuntimeException. 8 | * 9 | * This only exists as an intermediary since we needed to implement a few specific subclasses. 10 | */ 11 | public class RuntimeException extends Exception { 12 | static { 13 | // Shadow classes MUST be loaded during bootstrap phase. 14 | IInstrumentation.attachedThreadInstrumentation.get().bootstrapOnly(); 15 | } 16 | 17 | public RuntimeException() { 18 | super(); 19 | } 20 | 21 | public RuntimeException(String message) { 22 | super(message); 23 | } 24 | 25 | public RuntimeException(String message, Throwable cause) { 26 | super(message, cause); 27 | } 28 | 29 | public RuntimeException(Throwable cause) { 30 | super(cause); 31 | } 32 | 33 | // Deserializer support. 34 | public RuntimeException(java.lang.Void ignore, int readIndex) { 35 | super(ignore, readIndex); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /javaee/rt/src/java/s/java/lang/TypeNotPresentException.java: -------------------------------------------------------------------------------- 1 | package s.java.lang; 2 | 3 | import i.IInstrumentation; 4 | 5 | 6 | /** 7 | * Our shadow implementation of java.lang.TypeNotPresentException. 8 | */ 9 | public class TypeNotPresentException extends RuntimeException { 10 | static { 11 | // Shadow classes MUST be loaded during bootstrap phase. 12 | IInstrumentation.attachedThreadInstrumentation.get().bootstrapOnly(); 13 | } 14 | 15 | private String typeName; 16 | 17 | public TypeNotPresentException(String typeName, Throwable cause) { 18 | super(new String("Type " + typeName + " not present"), cause); 19 | this.typeName = typeName; 20 | } 21 | 22 | public TypeNotPresentException(java.lang.Void ignore, int readIndex) { 23 | super(ignore, readIndex); 24 | } 25 | 26 | //======================================================= 27 | // Methods below are used by runtime and test code only! 28 | //======================================================== 29 | 30 | public String typeName() { 31 | lazyLoad(); 32 | return typeName; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /javaee/rt/src/java/s/java/lang/Void.java: -------------------------------------------------------------------------------- 1 | package s.java.lang; 2 | 3 | import i.ConstantToken; 4 | import i.ShadowClassConstantId; 5 | 6 | public final class Void extends Object{ 7 | 8 | public static final Class avm_TYPE = new Class(java.lang.Void.TYPE, new ConstantToken(ShadowClassConstantId.Void_avm_TYPE)); 9 | 10 | /* 11 | * The Void class cannot be instantiated. 12 | */ 13 | private Void() { 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /javaee/rt/src/java/s/java/util/Collection.java: -------------------------------------------------------------------------------- 1 | package s.java.util; 2 | 3 | import i.IObject; 4 | import i.IObjectArray; 5 | import s.java.lang.Iterable; 6 | 7 | public interface Collection extends Iterable{ 8 | 9 | // Query Operations 10 | 11 | int avm_size(); 12 | 13 | boolean avm_isEmpty(); 14 | 15 | boolean avm_contains(IObject o); 16 | 17 | IObjectArray avm_toArray(); 18 | 19 | boolean avm_add(E e); 20 | 21 | boolean avm_remove(IObject o); 22 | 23 | boolean avm_containsAll(Collection c); 24 | 25 | boolean avm_addAll(Collection c); 26 | 27 | boolean avm_removeAll(Collection c); 28 | 29 | boolean avm_retainAll(Collection c); 30 | 31 | void avm_clear(); 32 | 33 | boolean avm_equals(IObject o); 34 | 35 | int avm_hashCode(); 36 | 37 | //Default 38 | 39 | 40 | //Exclude 41 | 42 | // T[] toArray(T[] a); 43 | } 44 | -------------------------------------------------------------------------------- /javaee/rt/src/java/s/java/util/Iterator.java: -------------------------------------------------------------------------------- 1 | package s.java.util; 2 | 3 | import i.IObject; 4 | 5 | public interface Iterator extends IObject { 6 | boolean avm_hasNext(); 7 | 8 | E avm_next(); 9 | 10 | default void avm_remove() { 11 | throw new UnsupportedOperationException("remove"); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /javaee/rt/src/java/s/java/util/ListIterator.java: -------------------------------------------------------------------------------- 1 | package s.java.util; 2 | 3 | import i.IObject; 4 | 5 | public interface ListIterator extends Iterator{ 6 | 7 | boolean avm_hasNext(); 8 | 9 | E avm_next(); 10 | 11 | boolean avm_hasPrevious(); 12 | 13 | E avm_previous(); 14 | 15 | int avm_nextIndex(); 16 | 17 | int avm_previousIndex(); 18 | 19 | void avm_remove(); 20 | 21 | void avm_set(E e); 22 | 23 | void avm_add(E e); 24 | 25 | } 26 | -------------------------------------------------------------------------------- /javaee/rt/src/java/s/java/util/NoSuchElementException.java: -------------------------------------------------------------------------------- 1 | package s.java.util; 2 | 3 | import i.IInstrumentation; 4 | import s.java.lang.RuntimeException; 5 | import s.java.lang.String; 6 | 7 | 8 | /** 9 | * Our shadow implementation of java.util.NoSuchElementException. 10 | * 11 | * Implemented manually since it only provides a subset of the usual exception constructors. 12 | */ 13 | public class NoSuchElementException extends RuntimeException { 14 | static { 15 | // Shadow classes MUST be loaded during bootstrap phase. 16 | IInstrumentation.attachedThreadInstrumentation.get().bootstrapOnly(); 17 | } 18 | 19 | public NoSuchElementException() { 20 | super(); 21 | } 22 | 23 | public NoSuchElementException(String message) { 24 | super(message); 25 | } 26 | 27 | // Deserializer support. 28 | public NoSuchElementException(Void ignore, int readIndex) { 29 | super(ignore, readIndex); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /javaee/rt/src/java/s/java/util/Set.java: -------------------------------------------------------------------------------- 1 | package s.java.util; 2 | 3 | import i.IObject; 4 | 5 | public interface Set extends Collection { 6 | } 7 | -------------------------------------------------------------------------------- /javaee/rt/src/java/s/java/util/function/Function.java: -------------------------------------------------------------------------------- 1 | package s.java.util.function; 2 | 3 | import i.IObject; 4 | 5 | /** 6 | * @author Roman Katerinenko 7 | */ 8 | public interface Function extends IObject { 9 | 10 | i.IObject avm_apply(i.IObject t) throws e.s.java.lang.Throwable; 11 | 12 | } -------------------------------------------------------------------------------- /javaee/rt/test/java/org/aion/avm/core/persistence/TargetArray.java: -------------------------------------------------------------------------------- 1 | package org.aion.avm.core.persistence; 2 | 3 | import i.IObjectDeserializer; 4 | import i.IObjectSerializer; 5 | 6 | 7 | public final class TargetArray extends TargetRoot { 8 | public Object[] array; 9 | public TargetArray(int size) { 10 | this.array = new Object[size]; 11 | } 12 | public TargetArray(Void ignore, int readIndex) { 13 | super(ignore, readIndex); 14 | } 15 | 16 | public void serializeSelf(Class stopBefore, IObjectSerializer serializer) { 17 | super.serializeSelf(TargetArray.class, serializer); 18 | serializer.writeInt(this.array.length); 19 | for (Object elt : this.array) { 20 | serializer.writeObject(elt); 21 | } 22 | } 23 | 24 | public void deserializeSelf(Class stopBefore, IObjectDeserializer deserializer) { 25 | super.deserializeSelf(TargetArray.class, deserializer); 26 | int size = deserializer.readInt(); 27 | this.array = new Object[size]; 28 | for (int i = 0; i < size; ++i) { 29 | this.array[i] = deserializer.readObject(); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /javaee/rt/test/java/org/aion/avm/core/persistence/TargetLeaf.java: -------------------------------------------------------------------------------- 1 | package org.aion.avm.core.persistence; 2 | 3 | 4 | public class TargetLeaf extends TargetRoot { 5 | public static double D; 6 | public TargetRoot left; 7 | public TargetRoot right; 8 | public TargetLeaf() { 9 | } 10 | public TargetLeaf(Void ignore, int readIndex) { 11 | super(ignore, readIndex); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /javaee/rt/test/java/org/aion/avm/core/persistence/TargetRoot.java: -------------------------------------------------------------------------------- 1 | package org.aion.avm.core.persistence; 2 | 3 | import i.IObjectDeserializer; 4 | import i.IObjectSerializer; 5 | 6 | 7 | public class TargetRoot { 8 | public static TargetRoot root; 9 | public final int readIndex; 10 | public int counter; 11 | public TargetRoot next; 12 | 13 | public TargetRoot() { 14 | this.readIndex = -1; 15 | } 16 | public TargetRoot(Void ignore, int readIndex) { 17 | this.readIndex = readIndex; 18 | } 19 | public void serializeSelf(Class stopBefore, IObjectSerializer serializer) { 20 | serializer.writeInt(this.counter); 21 | serializer.writeObject(this.next); 22 | serializer.automaticallySerializeToRoot((null == stopBefore) ? TargetRoot.class : stopBefore, this); 23 | } 24 | 25 | public void deserializeSelf(Class stopBefore, IObjectDeserializer deserializer) { 26 | this.counter = deserializer.readInt(); 27 | this.next = (TargetRoot) deserializer.readObject(); 28 | deserializer.automaticallyDeserializeFromRoot((null == stopBefore) ? TargetRoot.class : stopBefore, this); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /javaee/rt/test/java/org/aion/avm/core/persistence/TargetStatics.java: -------------------------------------------------------------------------------- 1 | package org.aion.avm.core.persistence; 2 | 3 | 4 | public class TargetStatics extends TargetRoot { 5 | public static TargetRoot left = new TargetLeaf(); 6 | public static TargetRoot right = new TargetLeaf(); 7 | 8 | public TargetStatics() { 9 | } 10 | public TargetStatics(Void ignore, int readIndex) { 11 | super(ignore, readIndex); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /javaee/rt/test/java/org/aion/avm/core/persistence/TestObjectSerializer.java: -------------------------------------------------------------------------------- 1 | package org.aion.avm.core.persistence; 2 | 3 | import java.nio.ByteBuffer; 4 | 5 | public class TestObjectSerializer { 6 | private final ByteBuffer buffer; 7 | 8 | public TestObjectSerializer(ByteBuffer buffer) { 9 | this.buffer = buffer; 10 | } 11 | 12 | public void writeInt(int value) { 13 | this.buffer.putInt(value); 14 | } 15 | 16 | public void writeIntArray(int[] value) { 17 | for (int i = 0; i < value.length; i++) { 18 | this.buffer.putInt(value[i]); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /javaee/samples/build.gradle: -------------------------------------------------------------------------------- 1 | dependencies { 2 | implementation project(':api') 3 | } 4 | 5 | sourceSets { 6 | main.java.srcDirs = [ 7 | 'collection/src', 8 | 'crowdsale/src', 9 | 'governance/src', 10 | 'multisig/src', 11 | 'sampletoken/src', 12 | 'testcases/src', 13 | 'tbcinterpreter/src', 14 | ] 15 | } 16 | 17 | compileJava { 18 | options.compilerArgs += ['-parameters'] 19 | } 20 | -------------------------------------------------------------------------------- /javaee/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'goloop-javaee' 2 | include 'rt', 3 | 'api', 4 | 'exec', 5 | 'tooling', 6 | 'logger', 7 | 'samples', 8 | 'app:allowlist', 9 | 'app:proxytest', 10 | 'app:execman', 11 | 'app:dappcomp' 12 | -------------------------------------------------------------------------------- /javaee/tooling/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'java-library' 2 | 3 | dependencies { 4 | implementation project(':api') 5 | implementation project(':rt') 6 | 7 | implementation 'org.msgpack:msgpack-core:0.8.17' 8 | implementation 'org.ow2.asm:asm:7.3.1' 9 | implementation 'org.ow2.asm:asm-commons:7.3.1' 10 | implementation 'org.ow2.asm:asm-util:7.3.1' 11 | implementation 'org.slf4j:slf4j-api:1.7.26' 12 | } 13 | -------------------------------------------------------------------------------- /javaee/tooling/src/java/foundation/icon/ee/tooling/abi/ABICompilerException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 ICON Foundation 3 | * Copyright (c) 2018 Aion Foundation https://aion.network/ 4 | */ 5 | 6 | package foundation.icon.ee.tooling.abi; 7 | 8 | public class ABICompilerException extends RuntimeException { 9 | 10 | public ABICompilerException(String exceptionString) { 11 | super(exceptionString); 12 | } 13 | 14 | public ABICompilerException(String exceptionString, String methodName) { 15 | super("Exception in method \"" + methodName + "\": " + exceptionString); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /javaee/tooling/src/java/org/aion/avm/tooling/deploy/eliminator/MethodInfo.java: -------------------------------------------------------------------------------- 1 | package org.aion.avm.tooling.deploy.eliminator; 2 | 3 | import java.util.HashSet; 4 | import java.util.Set; 5 | 6 | public class MethodInfo { 7 | 8 | public final String methodIdentifier; 9 | public final boolean isStatic; 10 | public final Set methodInvocations; 11 | public boolean isReachable = false; 12 | 13 | public MethodInfo(String methodIdentifier, boolean isStatic) { 14 | this.methodIdentifier = methodIdentifier; 15 | this.isStatic = isStatic; 16 | this.methodInvocations = new HashSet<>(); 17 | } 18 | 19 | public MethodInfo(String methodIdentifier, boolean isStatic, Set methodInvocations) { 20 | this.methodIdentifier = methodIdentifier; 21 | this.isStatic = isStatic; 22 | this.methodInvocations = methodInvocations; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /module/consensus.go: -------------------------------------------------------------------------------- 1 | package module 2 | 3 | type ConsensusStatus struct { 4 | Height int64 5 | Round int32 6 | Proposer bool 7 | } 8 | 9 | const ( 10 | FlagNextProofContext = 0x1 11 | FlagBTPBlockHeader = 0x2 12 | FlagBTPBlockProof = 0x4 13 | ) 14 | 15 | type Consensus interface { 16 | Start() error 17 | Term() 18 | GetStatus() *ConsensusStatus 19 | GetVotesByHeight(height int64) (CommitVoteSet, error) 20 | 21 | // GetBTPBlockHeaderAndProof returns header and proof according to the given 22 | // flag. 23 | GetBTPBlockHeaderAndProof( 24 | blk Block, nid int64, flag uint, 25 | ) (btpBlk BTPBlockHeader, proof []byte, err error) 26 | } 27 | -------------------------------------------------------------------------------- /module/patch.go: -------------------------------------------------------------------------------- 1 | package module 2 | 3 | const ( 4 | PatchTypeSkipTransaction = "skip_txs" 5 | ) 6 | 7 | type Patch interface { 8 | Type() string 9 | Data() []byte 10 | } 11 | 12 | type SkipTransactionPatch interface { 13 | Patch 14 | Height() int64 // height of the block to skip execution of 15 | 16 | // Verify check internal data is correct 17 | Verify(vl ValidatorList, roundLimit int64, nid int) error 18 | } 19 | 20 | type PatchDecoder func(t string, bs []byte) (Patch, error) 21 | -------------------------------------------------------------------------------- /pyee/README.md: -------------------------------------------------------------------------------- 1 | # Python Execution Engine 2 | -------------------------------------------------------------------------------- /pyee/VERSION: -------------------------------------------------------------------------------- 1 | 0.9.6 2 | -------------------------------------------------------------------------------- /pyee/pyexec/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2018 ICON Foundation 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from .service_engine import ServiceEngine 16 | from .iconscore.icon_score_context import IconScoreContext 17 | from .iconscore.icon_score_base import IconScoreBase 18 | from .ipc.proxy import ServiceManagerProxy 19 | -------------------------------------------------------------------------------- /pyee/pyexec/base/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2018 ICON Foundation 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | -------------------------------------------------------------------------------- /pyee/pyexec/database/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2018 ICON Foundation 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | -------------------------------------------------------------------------------- /pyee/pyexec/iconscore/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2018 ICON Foundation 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | -------------------------------------------------------------------------------- /pyee/pyexec/ipc/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2018 ICON Foundation 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from .proxy import * 16 | -------------------------------------------------------------------------------- /pyee/pyexec/logger/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2019 ICON Foundation 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from .logger import Logger, SystemLogger 16 | -------------------------------------------------------------------------------- /pyee/requirements.txt: -------------------------------------------------------------------------------- 1 | msgpack==0.6.2 2 | coincurve==13.0.0 3 | typing_extensions~=3.7.4.2 4 | -------------------------------------------------------------------------------- /pyee/tests/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 ICON Foundation 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | -------------------------------------------------------------------------------- /sdk/java/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id "maven-publish" 3 | id "com.jfrog.artifactory" version "4.17.2" 4 | id "com.jfrog.bintray" version "1.8.5" 5 | } 6 | 7 | subprojects { 8 | apply plugin: 'java' 9 | 10 | repositories { 11 | mavenCentral() 12 | } 13 | } 14 | 15 | apply from: 'publish.gradle' 16 | -------------------------------------------------------------------------------- /sdk/java/gradle.properties: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2018 ICON Foundation. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | 17 | GROUP=foundation.icon 18 | VERSION_NAME=2.0.0 19 | 20 | BINTRAY_USER_ORG=icon 21 | BINTRAY_REPO=icon-sdk 22 | BINTRAY_PKG_NAME=icon-sdk 23 | 24 | POM_ARTIFACT_ID=icon-sdk 25 | POM_DESCRIPTION=ICON SDK for goloop engine 26 | POM_URL=https://github.com/icon-project/goloop/tree/master/sdk/java 27 | -------------------------------------------------------------------------------- /sdk/java/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icon-project/goloop/67f6ff8433cef57fb9785e6065f0c94b8c1a86dd/sdk/java/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /sdk/java/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.5.1-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /sdk/java/library/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'java-library' 3 | } 4 | 5 | java { 6 | sourceCompatibility = JavaVersion.VERSION_1_8 7 | } 8 | 9 | sourceSets.main.java.srcDirs = ["src/main/java"] 10 | 11 | ext { 12 | bouncycastleVersion = '1.78.1' 13 | jacksonVersion = '2.13.4.2' 14 | okhttpVersion = '4.10.0' 15 | } 16 | 17 | dependencies { 18 | implementation "org.bouncycastle:bcprov-jdk18on:$bouncycastleVersion" 19 | implementation "com.fasterxml.jackson.core:jackson-databind:$jacksonVersion" 20 | implementation "com.squareup.okhttp3:okhttp:$okhttpVersion" 21 | } 22 | -------------------------------------------------------------------------------- /sdk/java/library/src/main/java/foundation/icon/icx/crypto/KeystoreException.java: -------------------------------------------------------------------------------- 1 | package foundation.icon.icx.crypto; 2 | 3 | /** 4 | * Original Code 5 | * https://github.com/web3j/web3j/blob/master/crypto/src/main/java/org/web3j/crypto/CipherException.java 6 | */ 7 | public class KeystoreException extends Exception { 8 | 9 | KeystoreException(String message) { 10 | super(message); 11 | } 12 | 13 | KeystoreException(Throwable cause) { 14 | super(cause); 15 | } 16 | 17 | KeystoreException(String message, Throwable cause) { 18 | super(message, cause); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /sdk/java/library/src/main/java/foundation/icon/icx/data/NetworkId.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 ICON Foundation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package foundation.icon.icx.data; 18 | 19 | import java.math.BigInteger; 20 | 21 | /** 22 | * Defines network ids 23 | */ 24 | public enum NetworkId { 25 | 26 | MAIN(new BigInteger("1")), 27 | TEST(new BigInteger("2")); 28 | 29 | private final BigInteger nid; 30 | 31 | NetworkId(BigInteger nid) { 32 | this.nid = nid; 33 | } 34 | 35 | public BigInteger getValue() { 36 | return nid; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /sdk/java/library/src/main/java/foundation/icon/icx/transport/jsonrpc/AnnotationConverter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 ICON Foundation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package foundation.icon.icx.transport.jsonrpc; 18 | 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | @Retention(RetentionPolicy.RUNTIME) 25 | @Target(ElementType.TYPE) 26 | public @interface AnnotationConverter { 27 | boolean use() default true; 28 | } 29 | -------------------------------------------------------------------------------- /sdk/java/library/src/main/java/foundation/icon/icx/transport/jsonrpc/RpcConverter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 ICON Foundation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package foundation.icon.icx.transport.jsonrpc; 18 | 19 | public interface RpcConverter { 20 | 21 | T convertTo(RpcItem object); 22 | 23 | RpcItem convertFrom(T object); 24 | 25 | interface RpcConverterFactory { 26 | RpcConverter create(Class type); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /sdk/java/library/src/main/java/foundation/icon/icx/transport/monitor/Monitor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 ICON Foundation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package foundation.icon.icx.transport.monitor; 18 | 19 | import java.math.BigInteger; 20 | 21 | public interface Monitor { 22 | interface Listener { 23 | void onStart(); 24 | void onEvent(T msg); 25 | void onError(long code); 26 | default void onProgress(BigInteger height) { } 27 | void onClose(); 28 | } 29 | 30 | boolean start(Listener listener); 31 | 32 | void stop(); 33 | } 34 | -------------------------------------------------------------------------------- /sdk/java/library/src/main/java/foundation/icon/icx/transport/monitor/MonitorSpec.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 ICON Foundation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package foundation.icon.icx.transport.monitor; 18 | 19 | import foundation.icon.icx.transport.jsonrpc.RpcObject; 20 | 21 | public abstract class MonitorSpec { 22 | protected String path; 23 | 24 | public abstract RpcObject getParams(); 25 | 26 | public String getPath() {return path;} 27 | public abstract Class getNotificationClass(); 28 | } 29 | -------------------------------------------------------------------------------- /sdk/java/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'icon-sdk' 2 | include 'library' 3 | -------------------------------------------------------------------------------- /server/error.go: -------------------------------------------------------------------------------- 1 | package server 2 | 3 | import ( 4 | "fmt" 5 | "net/http" 6 | 7 | "github.com/labstack/echo/v4" 8 | 9 | "github.com/icon-project/goloop/server/jsonrpc" 10 | ) 11 | 12 | func HTTPErrorHandler(err error, c echo.Context) { 13 | if je, ok := err.(*jsonrpc.Error); ok { 14 | jsonrpc.ErrorHandler(je, c) 15 | return 16 | } 17 | if he, ok := err.(*echo.HTTPError); ok { 18 | err = c.String(he.Code, fmt.Sprintf("%s %+v", he.Message, he.Internal)) 19 | } else { 20 | err = c.String(http.StatusInternalServerError, 21 | fmt.Sprintf("%+v", err)) 22 | } 23 | if err != nil { 24 | c.Echo().DefaultHTTPErrorHandler(err, c) 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /service/contract/customlogs.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 ICON Foundation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package contract 18 | 19 | type CustomLogs interface { 20 | Init(parent CustomLogs) CustomLogs 21 | Apply(data CustomLogs) 22 | } 23 | -------------------------------------------------------------------------------- /service/contract/errors.go: -------------------------------------------------------------------------------- 1 | package contract 2 | 3 | import ( 4 | "github.com/icon-project/goloop/common/errors" 5 | ) 6 | 7 | const ( 8 | PreparingContractError = iota + errors.CodeService + 200 9 | NoAvailableProxy 10 | ) 11 | -------------------------------------------------------------------------------- /service/eeproxy/enginefactory.go: -------------------------------------------------------------------------------- 1 | package eeproxy 2 | 3 | import ( 4 | "github.com/icon-project/goloop/common/errors" 5 | "github.com/icon-project/goloop/common/log" 6 | ) 7 | 8 | func AllocEngines(l log.Logger, names ...string) ([]Engine, error) { 9 | l.Infof("Allocate Engines:%s", names) 10 | if len(names) == 1 && names[0] == "none" { 11 | return make([]Engine,0), nil 12 | } 13 | engines := make([]Engine, len(names)) 14 | for i, name := range names { 15 | switch name { 16 | case "python": 17 | if engine, err := NewPythonEE(l); err != nil { 18 | return nil, err 19 | } else { 20 | engines[i] = engine 21 | } 22 | case "java": 23 | if engine, err := NewJavaEE(l); err != nil { 24 | return nil, err 25 | } else { 26 | engines[i] = engine 27 | } 28 | default: 29 | return nil, errors.IllegalArgumentError.Errorf( 30 | "IllegalEngineName(name=%s)", name) 31 | } 32 | } 33 | return engines, nil 34 | } 35 | -------------------------------------------------------------------------------- /service/error.go: -------------------------------------------------------------------------------- 1 | package service 2 | 3 | import "github.com/icon-project/goloop/common/errors" 4 | 5 | const ( 6 | DuplicateTransactionError errors.Code = iota + errors.CodeService 7 | TransactionPoolOverflowError 8 | ExpiredTransactionError 9 | FutureTransactionError 10 | TransitionInterruptedError 11 | InvalidTransactionError 12 | InvalidQueryError 13 | InvalidResultError 14 | NoActiveContractError 15 | NotContractAddressError 16 | InvalidPatchDataError 17 | CommittedTransactionError 18 | ) 19 | 20 | var ( 21 | ErrDuplicateTransaction = errors.NewBase(DuplicateTransactionError, "DuplicateTransaction") 22 | ErrTransactionPoolOverFlow = errors.NewBase(TransactionPoolOverflowError, "TransactionPoolOverFlow") 23 | ErrExpiredTransaction = errors.NewBase(ExpiredTransactionError, "ExpiredTransaction") 24 | ErrTransitionInterrupted = errors.NewBase(TransitionInterruptedError, "TransitionInterrupted") 25 | ErrInvalidTransaction = errors.NewBase(InvalidTransactionError, "InvalidTransaction") 26 | ErrCommittedTransaction = errors.NewBase(CommittedTransactionError, "CommittedTransaction") 27 | ) 28 | -------------------------------------------------------------------------------- /service/inspect.go: -------------------------------------------------------------------------------- 1 | package service 2 | 3 | import ( 4 | "github.com/icon-project/goloop/module" 5 | ) 6 | 7 | func Inspect(c module.Chain, informal bool) map[string]interface{} { 8 | var mgr *manager 9 | if sm := c.ServiceManager(); sm == nil { 10 | return nil 11 | } else { 12 | if impl, ok := sm.(*manager); ok { 13 | mgr = impl 14 | } else { 15 | return nil 16 | } 17 | } 18 | m := make(map[string]interface{}) 19 | m["normalTxPool"] = inspectTxPool(mgr.tm.normalTxPool) 20 | m["patchTxPool"] = inspectTxPool(mgr.tm.patchTxPool) 21 | m["resultCache"] = inspectResultCache(mgr.trc) 22 | return m 23 | } 24 | 25 | func inspectResultCache(tsc *transitionResultCache) map[string]interface{} { 26 | m := make(map[string]interface{}) 27 | m["used"] = tsc.Count() 28 | m["size"] = tsc.MaxCount() 29 | m["bytes"] = tsc.TotalBytes() 30 | return m 31 | } 32 | 33 | func inspectTxPool(p *TransactionPool) map[string]interface{} { 34 | m := make(map[string]interface{}) 35 | m["size"] = p.Size() 36 | m["used"] = p.Used() 37 | return m 38 | } 39 | -------------------------------------------------------------------------------- /service/scoreapi/error.go: -------------------------------------------------------------------------------- 1 | package scoreapi 2 | 3 | import "github.com/icon-project/goloop/common/errors" 4 | 5 | const ( 6 | errorBase = errors.CodeService + 400 7 | NoSignatureError = errorBase + iota 8 | IllegalEventError 9 | ) 10 | 11 | var ( 12 | ErrNoSignature = errors.NewBase(NoSignatureError, "NoSignatureError") 13 | ErrIllegalEvent = errors.NewBase(IllegalEventError, "IllegalEventError") 14 | ) 15 | -------------------------------------------------------------------------------- /service/state/worldcontext_icon.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 ICON Foundation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package state 18 | 19 | import "github.com/icon-project/goloop/common" 20 | 21 | const ( 22 | VarBlockedScores = "blocked_scores" 23 | ) 24 | 25 | const ( 26 | LostIDStr = "\x20\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" 27 | ) 28 | 29 | var ( 30 | LostID = []byte(LostIDStr) 31 | LostAddress = common.NewAccountAddress(LostID) 32 | ) 33 | -------------------------------------------------------------------------------- /service/sync2/protocolv2.go: -------------------------------------------------------------------------------- 1 | package sync2 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/icon-project/goloop/common/db" 7 | "github.com/icon-project/goloop/module" 8 | ) 9 | 10 | // protocol message codes 11 | const ( 12 | protoV2Request module.ProtocolInfo = iota 13 | protoV2Response 14 | ) 15 | 16 | var protocolv2 = []module.ProtocolInfo{ 17 | protoV2Request, 18 | protoV2Response, 19 | } 20 | 21 | type BucketIDAndBytes struct { 22 | BkID db.BucketID 23 | Bytes []byte 24 | } 25 | 26 | func (b BucketIDAndBytes) String() string { 27 | return fmt.Sprintf("{BkID:%s, Bytes:%#x}", b.BkID, b.Bytes) 28 | } 29 | 30 | type requestData struct { 31 | ReqID uint32 32 | Data []BucketIDAndBytes 33 | } 34 | 35 | func (r *requestData) String() string { 36 | return fmt.Sprintf("ReqID=%d, Data=%+v", r.ReqID, r.Data) 37 | } 38 | 39 | type responseData struct { 40 | ReqID uint32 41 | Status errCode 42 | Data []BucketIDAndBytes 43 | } 44 | 45 | func (r *responseData) String() string { 46 | return fmt.Sprintf("ReqID=%d, Status=%d, Data=%+v", 47 | r.ReqID, r.Status, r.Data) 48 | } 49 | -------------------------------------------------------------------------------- /service/trace/traceblock.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 ICON Foundation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package trace 18 | 19 | import "github.com/icon-project/goloop/module" 20 | 21 | type traceBlock struct { 22 | id []byte 23 | rl module.ReceiptList 24 | } 25 | 26 | func (b *traceBlock) ID() []byte { 27 | return b.id 28 | } 29 | 30 | func (b *traceBlock) GetReceipt(txIndex int) module.Receipt { 31 | if b.rl == nil { 32 | return nil 33 | } 34 | rct, _ := b.rl.Get(txIndex) 35 | return rct 36 | } 37 | 38 | func NewTraceBlock(id []byte, rl module.ReceiptList) module.TraceBlock { 39 | return &traceBlock{id, rl} 40 | } 41 | -------------------------------------------------------------------------------- /service/trace/util.go: -------------------------------------------------------------------------------- 1 | package trace 2 | 3 | import ( 4 | "bytes" 5 | "encoding/json" 6 | "fmt" 7 | ) 8 | 9 | func ToJSON(v interface{}) string { 10 | bs, err := json.MarshalIndent(v, "", "") 11 | if err != nil { 12 | return fmt.Sprintf("%v", v) 13 | } 14 | buf := bytes.NewBuffer(nil) 15 | err = json.Compact(buf, bs) 16 | if err != nil { 17 | return fmt.Sprintf("%v", v) 18 | } 19 | return buf.String() 20 | } 21 | -------------------------------------------------------------------------------- /service/transaction/errors.go: -------------------------------------------------------------------------------- 1 | package transaction 2 | 3 | import ( 4 | "github.com/icon-project/goloop/common/errors" 5 | ) 6 | 7 | const ( 8 | InvalidGenesisError = iota + errors.CodeService + 100 9 | InvalidSignatureError 10 | InvalidVersion 11 | InvalidTxValue 12 | InvalidFormat 13 | NotEnoughStepError 14 | NotEnoughBalanceError 15 | ContractNotUsable 16 | AccessDeniedError 17 | ) 18 | -------------------------------------------------------------------------------- /service/transaction/factory_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 ICON Foundation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package transaction 18 | 19 | import ( 20 | "testing" 21 | ) 22 | 23 | func FuzzNewTransaction(f *testing.F) { 24 | f.Fuzz(func(t *testing.T, data []byte) { 25 | tx, err := newTransaction(data) 26 | if err == nil { 27 | tx.Verify() 28 | } 29 | }) 30 | } 31 | -------------------------------------------------------------------------------- /service/transaction/patchtransaction.go: -------------------------------------------------------------------------------- 1 | package transaction 2 | 3 | import ( 4 | "encoding/json" 5 | 6 | "github.com/icon-project/goloop/common" 7 | "github.com/icon-project/goloop/module" 8 | "github.com/icon-project/goloop/service/contract" 9 | "github.com/icon-project/goloop/service/state" 10 | ) 11 | 12 | func NewPatchTransaction(p module.Patch, nid int, ts int64, w module.Wallet) (Transaction, error) { 13 | var v3tx transactionV3 14 | // fill data 15 | tx := &v3tx.transactionV3Data 16 | tx.Version.Value = module.TransactionVersion3 17 | tx.From.Set(w.Address()) 18 | tx.To.SetTypeAndID(true, state.SystemID) 19 | tx.TimeStamp.Value = ts 20 | tx.NID = &common.HexInt64{Value: int64(nid)} 21 | dt := contract.DataTypePatch 22 | tx.DataType = &dt 23 | data := &contract.Patch{ 24 | Type: p.Type(), 25 | Data: p.Data(), 26 | } 27 | js, err := json.Marshal(data) 28 | if err != nil { 29 | return nil, err 30 | } 31 | tx.Data = js 32 | 33 | // sign 34 | sig, err := w.Sign(v3tx.TxHash()) 35 | if err != nil { 36 | return nil, err 37 | } 38 | if err := tx.Signature.UnmarshalBinary(sig); err != nil { 39 | return nil, err 40 | } 41 | return &transaction{&v3tx}, nil 42 | } 43 | -------------------------------------------------------------------------------- /service/transition_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 ICON Foundation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package service 18 | 19 | import ( 20 | "testing" 21 | 22 | "github.com/stretchr/testify/assert" 23 | ) 24 | 25 | func TestTransitionID(t *testing.T) { 26 | id1 := new(transitionID) 27 | id2 := new(transitionID) 28 | assert.False(t, id1 == id2) 29 | } 30 | -------------------------------------------------------------------------------- /service/txresult/receipt_icon.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 ICON Foundation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package txresult 18 | 19 | func init() { 20 | signaturePatches["ICXBurned"] = "ICXBurned(int)" 21 | } 22 | -------------------------------------------------------------------------------- /service/txshare_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 ICON Foundation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package service 18 | 19 | import "testing" 20 | 21 | func FuzzTestMsgTransactionRequest(f *testing.F) { 22 | f.Fuzz(func(t *testing.T, b []byte) { 23 | var msg msgTransactionRequest 24 | msg.SetBytes(b) 25 | msg.GetBloom() 26 | }) 27 | } 28 | -------------------------------------------------------------------------------- /testsuite/data/chainenv/java.props: -------------------------------------------------------------------------------- 1 | node0.url=http://localhost:9082 2 | node0.wallet=keystore_god.json 3 | node0.walletPassword=gochain 4 | node0.channel0.nid=0x3 5 | node0.channel0.name=default 6 | 7 | chain0.nid=0x3 8 | chain0.godWallet=keystore_god.json 9 | chain0.godPassword=gochain 10 | chain0.totalSupply=0x2961fff8ca4a62327800000 11 | -------------------------------------------------------------------------------- /testsuite/data/chainenv/javagov.props: -------------------------------------------------------------------------------- 1 | node0.url=http://localhost:9083 2 | node0.wallet=keystore_god.json 3 | node0.walletPassword=gochain 4 | node0.channel0.nid=0x4 5 | node0.channel0.name=default 6 | 7 | chain0.nid=0x4 8 | chain0.godWallet=keystore_god.json 9 | chain0.godPassword=gochain 10 | chain0.govWallet=keystore_gov.json 11 | chain0.govPassword=gochain 12 | chain0.totalSupply=0x2961fff8ca4a62327800000 13 | -------------------------------------------------------------------------------- /testsuite/data/chainenv/py.props: -------------------------------------------------------------------------------- 1 | node0.url=http://localhost:9080 2 | node0.channel0.nid=0x1 3 | node0.channel0.name=default 4 | 5 | chain0.nid=0x1 6 | chain0.godWallet=keystore_god.json 7 | chain0.godPassword=gochain 8 | chain0.totalSupply=0x2961fff8ca4a62327800000 9 | -------------------------------------------------------------------------------- /testsuite/data/chainenv/pygov.props: -------------------------------------------------------------------------------- 1 | node0.url=http://localhost:9081 2 | node0.wallet=keystore_god.json 3 | node0.walletPassword=gochain 4 | node0.channel0.nid=0x2 5 | node0.channel0.name=default 6 | 7 | chain0.nid=0x2 8 | chain0.godWallet=keystore_god.json 9 | chain0.godPassword=gochain 10 | chain0.govWallet=keystore_gov.json 11 | chain0.govPassword=gochain 12 | chain0.totalSupply=0x2961fff8ca4a62327800000 13 | -------------------------------------------------------------------------------- /testsuite/data/config/javagov.json: -------------------------------------------------------------------------------- 1 | { 2 | "nid": 4, 3 | "channel": "default", 4 | "concurrency_level": 1, 5 | "db_type": "goleveldb", 6 | "ee_instances": 1, 7 | "ee_socket": "", 8 | "engines": "python,java", 9 | "p2p": "127.0.0.1:8083", 10 | "p2p_listen": "", 11 | "role": 2, 12 | "rpc_addr": ":9083", 13 | "rpc_debug": true, 14 | "rpc_dump": true, 15 | "seed_addr": "", 16 | "waitTimeout": 3000, 17 | "key_store": { 18 | "address": "hxb6b5791be0b5ef67063b3c10b840fb81514db2fd", 19 | "id": "87323a66-289a-4ce2-88e4-00278deb5b84", 20 | "version": 3, 21 | "coinType": "icx", 22 | "crypto": { 23 | "cipher": "aes-128-ctr", 24 | "cipherparams": { 25 | "iv": "069e46aaefae8f1c1f840d6b09144999" 26 | }, 27 | "ciphertext": "f35ff7cf4f5759cb0878088d0887574a896f7f0fc2a73898d88be1fe52977dbd", 28 | "kdf": "scrypt", 29 | "kdfparams": { 30 | "dklen": 32, 31 | "n": 65536, 32 | "r": 8, 33 | "p": 1, 34 | "salt": "0fc9c3b24cdb8175" 35 | }, 36 | "mac": "1ef4ff51fdee8d4de9cf59e160da049eb0099eb691510994f5eca492f56c817a" 37 | } 38 | }, 39 | "key_password": "gochain" 40 | } 41 | -------------------------------------------------------------------------------- /testsuite/data/config/pygov.json: -------------------------------------------------------------------------------- 1 | { 2 | "nid": 2, 3 | "channel": "default", 4 | "concurrency_level": 1, 5 | "db_type": "goleveldb", 6 | "ee_instances": 1, 7 | "ee_socket": "", 8 | "engines": "python", 9 | "p2p": "127.0.0.1:8081", 10 | "p2p_listen": "", 11 | "role": 2, 12 | "rpc_addr": ":9081", 13 | "rpc_debug": true, 14 | "rpc_dump": true, 15 | "seed_addr": "", 16 | "waitTimeout": 3000, 17 | "key_store": { 18 | "address": "hxb6b5791be0b5ef67063b3c10b840fb81514db2fd", 19 | "id": "87323a66-289a-4ce2-88e4-00278deb5b84", 20 | "version": 3, 21 | "coinType": "icx", 22 | "crypto": { 23 | "cipher": "aes-128-ctr", 24 | "cipherparams": { 25 | "iv": "069e46aaefae8f1c1f840d6b09144999" 26 | }, 27 | "ciphertext": "f35ff7cf4f5759cb0878088d0887574a896f7f0fc2a73898d88be1fe52977dbd", 28 | "kdf": "scrypt", 29 | "kdfparams": { 30 | "dklen": 32, 31 | "n": 65536, 32 | "r": 8, 33 | "p": 1, 34 | "salt": "0fc9c3b24cdb8175" 35 | }, 36 | "mac": "1ef4ff51fdee8d4de9cf59e160da049eb0099eb691510994f5eca492f56c817a" 37 | } 38 | }, 39 | "key_password": "gochain" 40 | } 41 | -------------------------------------------------------------------------------- /testsuite/data/dockerenv/javagov: -------------------------------------------------------------------------------- 1 | GOCHAIN_CONFIG=/testsuite/data/config/javagov.json 2 | GOCHAIN_GENESIS=/testsuite/data/genesisStorage/genesis_javagov.json 3 | GOCHAIN_DATA=/testsuite/.chain/javagov 4 | GOCHAIN_LOGFILE=/testsuite/.chain/javagov.log 5 | GOCHAIN_CLEAN_DATA=true 6 | JAVAEE_BIN=/goloop/execman/bin/execman 7 | -------------------------------------------------------------------------------- /testsuite/data/dockerenv/javascore: -------------------------------------------------------------------------------- 1 | GOCHAIN_CONFIG=/testsuite/data/config/java.json 2 | GOCHAIN_DATA=/testsuite/.chain/javascore 3 | GOCHAIN_LOGFILE=/testsuite/.chain/javascore.log 4 | GOCHAIN_CLEAN_DATA=true 5 | JAVAEE_BIN=/goloop/execman/bin/execman 6 | -------------------------------------------------------------------------------- /testsuite/data/dockerenv/pyaudit: -------------------------------------------------------------------------------- 1 | GOCHAIN_CONFIG=/testsuite/data/config/pygov.json 2 | GOCHAIN_GENESIS=/testsuite/data/genesisStorage/genesis_audit.json 3 | GOCHAIN_DATA=/testsuite/.chain/pyaudit 4 | GOCHAIN_LOGFILE=/testsuite/.chain/pyaudit.log 5 | GOCHAIN_CLEAN_DATA=true 6 | -------------------------------------------------------------------------------- /testsuite/data/dockerenv/pygov: -------------------------------------------------------------------------------- 1 | GOCHAIN_CONFIG=/testsuite/data/config/pygov.json 2 | GOCHAIN_GENESIS=/testsuite/data/genesisStorage/genesis_gov.json 3 | GOCHAIN_DATA=/testsuite/.chain/pygov 4 | GOCHAIN_LOGFILE=/testsuite/.chain/pygov.log 5 | GOCHAIN_CLEAN_DATA=true 6 | -------------------------------------------------------------------------------- /testsuite/data/dockerenv/pyscore: -------------------------------------------------------------------------------- 1 | GOCHAIN_CONFIG=/testsuite/data/config/py.json 2 | GOCHAIN_DATA=/testsuite/.chain/pyscore 3 | GOCHAIN_LOGFILE=/testsuite/.chain/pyscore.log 4 | GOCHAIN_CLEAN_DATA=true 5 | -------------------------------------------------------------------------------- /testsuite/data/genesisStorage/genesis_py.json: -------------------------------------------------------------------------------- 1 | { 2 | "accounts": [ 3 | { 4 | "address": "hxb6b5791be0b5ef67063b3c10b840fb81514db2fd", 5 | "balance": "0x2961fff8ca4a62327800000", 6 | "name": "god" 7 | }, 8 | { 9 | "address": "hx1000000000000000000000000000000000000000", 10 | "balance": "0x0", 11 | "name": "treasury" 12 | } 13 | ], 14 | "chain": { 15 | "revision": "0x8", 16 | "validatorList": [ 17 | "hxb6b5791be0b5ef67063b3c10b840fb81514db2fd" 18 | ] 19 | }, 20 | "message": "genesis for CI tests", 21 | "nid": "0x1" 22 | } 23 | -------------------------------------------------------------------------------- /testsuite/data/genesisStorage/governance-optimized.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icon-project/goloop/67f6ff8433cef57fb9785e6065f0c94b8c1a86dd/testsuite/data/genesisStorage/governance-optimized.jar -------------------------------------------------------------------------------- /testsuite/data/genesisStorage/governance/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icon-project/goloop/67f6ff8433cef57fb9785e6065f0c94b8c1a86dd/testsuite/data/genesisStorage/governance/__init__.py -------------------------------------------------------------------------------- /testsuite/data/genesisStorage/governance/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.0.1", 3 | "main_module": "governance", 4 | "main_score": "Governance" 5 | } 6 | -------------------------------------------------------------------------------- /testsuite/data/keystore_god.json: -------------------------------------------------------------------------------- 1 | { 2 | "address": "hxb6b5791be0b5ef67063b3c10b840fb81514db2fd", 3 | "id": "87323a66-289a-4ce2-88e4-00278deb5b84", 4 | "version": 3, 5 | "coinType": "icx", 6 | "crypto": { 7 | "cipher": "aes-128-ctr", 8 | "cipherparams": { 9 | "iv": "069e46aaefae8f1c1f840d6b09144999" 10 | }, 11 | "ciphertext": "f35ff7cf4f5759cb0878088d0887574a896f7f0fc2a73898d88be1fe52977dbd", 12 | "kdf": "scrypt", 13 | "kdfparams": { 14 | "dklen": 32, 15 | "n": 65536, 16 | "r": 8, 17 | "p": 1, 18 | "salt": "0fc9c3b24cdb8175" 19 | }, 20 | "mac": "1ef4ff51fdee8d4de9cf59e160da049eb0099eb691510994f5eca492f56c817a" 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /testsuite/data/keystore_gov.json: -------------------------------------------------------------------------------- 1 | {"address":"hx54f021fc4a755a2a2c9fdda47a16ce4cd3f3b43e","id":"fec5bce7-a95d-4e55-960c-0eb6032df9bf","version":3,"coinType":"icx","crypto":{"cipher":"aes-128-ctr","cipherparams":{"iv":"f5ad0f4544a3a1b65c738cdfe0237773"},"ciphertext":"4c183195be375c4921978a710c4ca9679a556aeb4a024743ce89599f4cf2bc85","kdf":"scrypt","kdfparams":{"dklen":32,"n":65536,"r":8,"p":1,"salt":"190a4bef3f836b90"},"mac":"7e0eb4fa6ab4b47c58e1862d8de2b0d316f88e15d64207b23fdf97c31bf0d2cd"}} -------------------------------------------------------------------------------- /testsuite/data/resource/invalidJars/Case1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icon-project/goloop/67f6ff8433cef57fb9785e6065f0c94b8c1a86dd/testsuite/data/resource/invalidJars/Case1.jar -------------------------------------------------------------------------------- /testsuite/data/scores/check_params/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icon-project/goloop/67f6ff8433cef57fb9785e6065f0c94b8c1a86dd/testsuite/data/scores/check_params/__init__.py -------------------------------------------------------------------------------- /testsuite/data/scores/check_params/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.0.1", 3 | "main_module": "check_params", 4 | "main_score": "CheckParams" 5 | } 6 | -------------------------------------------------------------------------------- /testsuite/data/scores/container_db/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icon-project/goloop/67f6ff8433cef57fb9785e6065f0c94b8c1a86dd/testsuite/data/scores/container_db/__init__.py -------------------------------------------------------------------------------- /testsuite/data/scores/container_db/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.0.1", 3 | "main_module": "container_db", 4 | "main_score": "ContainerDB" 5 | } 6 | -------------------------------------------------------------------------------- /testsuite/data/scores/db_step/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icon-project/goloop/67f6ff8433cef57fb9785e6065f0c94b8c1a86dd/testsuite/data/scores/db_step/__init__.py -------------------------------------------------------------------------------- /testsuite/data/scores/db_step/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.0.1", 3 | "main_module": "db_step", 4 | "main_score": "DbStep" 5 | } -------------------------------------------------------------------------------- /testsuite/data/scores/event_gen/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icon-project/goloop/67f6ff8433cef57fb9785e6065f0c94b8c1a86dd/testsuite/data/scores/event_gen/__init__.py -------------------------------------------------------------------------------- /testsuite/data/scores/event_gen/event_gen.py: -------------------------------------------------------------------------------- 1 | from iconservice import * 2 | 3 | TAG = 'EventGen' 4 | 5 | 6 | class EventGen(IconScoreBase): 7 | def __init__(self, db: IconScoreDatabase) -> None: 8 | super().__init__(db) 9 | 10 | def on_install(self, name: str) -> None: 11 | super().on_install() 12 | Logger.info(f'on_install: name={name}', TAG) 13 | 14 | def on_update(self) -> None: 15 | super().on_update() 16 | 17 | @eventlog(indexed=3) 18 | def Event(self, _addr: Address, _int: int, _bytes: bytes): 19 | pass 20 | 21 | @external 22 | def generate(self, _addr: Address, _int: int, _bytes: bytes): 23 | self.Event(_addr, _int, _bytes) 24 | 25 | @eventlog(indexed=3) 26 | def EventEx(self, _bool: bool, _int: int, _str: str, _addr: Address, _bytes: bytes): 27 | pass 28 | 29 | @external 30 | def generateNullByIndex(self, _idx: int): 31 | args = [True, 1, "test", Address.from_string("hx0000000000000000000000000000000000000000"), bytes([1])] 32 | args[_idx] = None 33 | self.EventEx(*args) 34 | 35 | @payable 36 | def fallback(self): 37 | Logger.info('fallback is called', TAG) 38 | 39 | -------------------------------------------------------------------------------- /testsuite/data/scores/event_gen/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.0.1", 3 | "main_module": "event_gen", 4 | "main_score": "EventGen" 5 | } 6 | -------------------------------------------------------------------------------- /testsuite/data/scores/fee_sharing/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icon-project/goloop/67f6ff8433cef57fb9785e6065f0c94b8c1a86dd/testsuite/data/scores/fee_sharing/__init__.py -------------------------------------------------------------------------------- /testsuite/data/scores/fee_sharing/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.0.1", 3 | "main_module": "fee_sharing", 4 | "main_score": "FeeSharing" 5 | } 6 | -------------------------------------------------------------------------------- /testsuite/data/scores/governance/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icon-project/goloop/67f6ff8433cef57fb9785e6065f0c94b8c1a86dd/testsuite/data/scores/governance/__init__.py -------------------------------------------------------------------------------- /testsuite/data/scores/governance/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.0.1", 3 | "main_module": "governance", 4 | "main_score": "Governance" 5 | } 6 | -------------------------------------------------------------------------------- /testsuite/data/scores/hello_world/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icon-project/goloop/67f6ff8433cef57fb9785e6065f0c94b8c1a86dd/testsuite/data/scores/hello_world/__init__.py -------------------------------------------------------------------------------- /testsuite/data/scores/hello_world/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.0.1", 3 | "main_module": "hello_world", 4 | "main_score": "HelloWorld" 5 | } 6 | -------------------------------------------------------------------------------- /testsuite/data/scores/hello_world2/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icon-project/goloop/67f6ff8433cef57fb9785e6065f0c94b8c1a86dd/testsuite/data/scores/hello_world2/__init__.py -------------------------------------------------------------------------------- /testsuite/data/scores/hello_world2/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.0.1", 3 | "main_module": "hello_world", 4 | "main_score": "HelloWorld" 5 | } 6 | -------------------------------------------------------------------------------- /testsuite/data/scores/method_caller/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icon-project/goloop/67f6ff8433cef57fb9785e6065f0c94b8c1a86dd/testsuite/data/scores/method_caller/__init__.py -------------------------------------------------------------------------------- /testsuite/data/scores/method_caller/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.0.0", 3 | "main_module": "method_caller", 4 | "main_score": "MethodCaller" 5 | } 6 | -------------------------------------------------------------------------------- /testsuite/data/scores/multisig_wallet/__init__.py: -------------------------------------------------------------------------------- 1 | from .multisig_wallet import MultiSigWallet -------------------------------------------------------------------------------- /testsuite/data/scores/multisig_wallet/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.9.2", 3 | "main_file": "multisig_wallet", 4 | "main_score": "MultiSigWallet" 5 | } -------------------------------------------------------------------------------- /testsuite/data/scores/multisig_wallet/qualification_check/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icon-project/goloop/67f6ff8433cef57fb9785e6065f0c94b8c1a86dd/testsuite/data/scores/multisig_wallet/qualification_check/__init__.py -------------------------------------------------------------------------------- /testsuite/data/scores/multisig_wallet/type_converter/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icon-project/goloop/67f6ff8433cef57fb9785e6065f0c94b8c1a86dd/testsuite/data/scores/multisig_wallet/type_converter/__init__.py -------------------------------------------------------------------------------- /testsuite/data/scores/no_install_method/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icon-project/goloop/67f6ff8433cef57fb9785e6065f0c94b8c1a86dd/testsuite/data/scores/no_install_method/__init__.py -------------------------------------------------------------------------------- /testsuite/data/scores/no_install_method/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.0.1", 3 | "main_module": "no_install_method", 4 | "main_score": "NoInstallMethod" 5 | } 6 | -------------------------------------------------------------------------------- /testsuite/data/scores/no_update_method/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icon-project/goloop/67f6ff8433cef57fb9785e6065f0c94b8c1a86dd/testsuite/data/scores/no_update_method/__init__.py -------------------------------------------------------------------------------- /testsuite/data/scores/no_update_method/no_update_method.py: -------------------------------------------------------------------------------- 1 | from iconservice import * 2 | 3 | TAG = 'NoUpdate' 4 | 5 | class NoUpdateMethod(IconScoreBase): 6 | 7 | def __init__(self, db: IconScoreDatabase) -> None: 8 | super().__init__(db) 9 | 10 | def on_install(self, name: str) -> None: 11 | super().on_install() 12 | 13 | @external(readonly=True) 14 | def name(self) -> str: 15 | return "HelloWorld" 16 | 17 | @external 18 | def hello(self): 19 | Logger.info('Hello, world!', TAG) 20 | 21 | @external 22 | def helloWithName2(self, name: str): 23 | Logger.info('Hello 2 %s' % name, TAG) 24 | 25 | @payable 26 | def fallback(self): 27 | Logger.info('fallback is called', TAG) 28 | 29 | @external 30 | def tokenFallback(self, _from: Address, _value: int, _data: bytes): 31 | Logger.info('tokenFallback is called', TAG) 32 | -------------------------------------------------------------------------------- /testsuite/data/scores/no_update_method/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.0.1", 3 | "main_module": "no_update_method", 4 | "main_score": "NoUpdateMethod" 5 | } 6 | -------------------------------------------------------------------------------- /testsuite/data/scores/receipt/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icon-project/goloop/67f6ff8433cef57fb9785e6065f0c94b8c1a86dd/testsuite/data/scores/receipt/__init__.py -------------------------------------------------------------------------------- /testsuite/data/scores/receipt/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.0.1", 3 | "main_module": "receipt", 4 | "main_score": "Receipt" 5 | } 6 | -------------------------------------------------------------------------------- /testsuite/data/scores/result_gen/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icon-project/goloop/67f6ff8433cef57fb9785e6065f0c94b8c1a86dd/testsuite/data/scores/result_gen/__init__.py -------------------------------------------------------------------------------- /testsuite/data/scores/result_gen/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.0.1", 3 | "main_module": "result_gen", 4 | "main_score": "ResultGenerator" 5 | } 6 | -------------------------------------------------------------------------------- /testsuite/data/scores/sample_crowdsale/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icon-project/goloop/67f6ff8433cef57fb9785e6065f0c94b8c1a86dd/testsuite/data/scores/sample_crowdsale/__init__.py -------------------------------------------------------------------------------- /testsuite/data/scores/sample_crowdsale/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.0.1", 3 | "main_module": "sample_crowdsale", 4 | "main_score": "SampleCrowdsale" 5 | } 6 | -------------------------------------------------------------------------------- /testsuite/data/scores/sample_token/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icon-project/goloop/67f6ff8433cef57fb9785e6065f0c94b8c1a86dd/testsuite/data/scores/sample_token/__init__.py -------------------------------------------------------------------------------- /testsuite/data/scores/sample_token/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.0.1", 3 | "main_module": "sample_token", 4 | "main_score": "SampleToken" 5 | } -------------------------------------------------------------------------------- /testsuite/data/scores/score_api/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icon-project/goloop/67f6ff8433cef57fb9785e6065f0c94b8c1a86dd/testsuite/data/scores/score_api/__init__.py -------------------------------------------------------------------------------- /testsuite/data/scores/score_api/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.0.1", 3 | "main_module": "score_api", 4 | "main_score": "ScoreApi" 5 | } 6 | -------------------------------------------------------------------------------- /testsuite/data/scores/step_counter/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icon-project/goloop/67f6ff8433cef57fb9785e6065f0c94b8c1a86dd/testsuite/data/scores/step_counter/__init__.py -------------------------------------------------------------------------------- /testsuite/data/scores/step_counter/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.0.1", 3 | "main_module": "step_counter", 4 | "main_score": "StepCounter" 5 | } -------------------------------------------------------------------------------- /testsuite/data/scores/tbc_interpreter/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icon-project/goloop/67f6ff8433cef57fb9785e6065f0c94b8c1a86dd/testsuite/data/scores/tbc_interpreter/__init__.py -------------------------------------------------------------------------------- /testsuite/data/scores/tbc_interpreter/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.0.1", 3 | "main_module": "tbc_interpreter", 4 | "main_score": "TBCInterpreter" 5 | } 6 | -------------------------------------------------------------------------------- /testsuite/data/scores/too_big/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icon-project/goloop/67f6ff8433cef57fb9785e6065f0c94b8c1a86dd/testsuite/data/scores/too_big/__init__.py -------------------------------------------------------------------------------- /testsuite/data/scores/too_big/month_1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icon-project/goloop/67f6ff8433cef57fb9785e6065f0c94b8c1a86dd/testsuite/data/scores/too_big/month_1.jpg -------------------------------------------------------------------------------- /testsuite/data/scores/too_big/month_2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icon-project/goloop/67f6ff8433cef57fb9785e6065f0c94b8c1a86dd/testsuite/data/scores/too_big/month_2.jpg -------------------------------------------------------------------------------- /testsuite/data/scores/too_big/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.0.1", 3 | "main_module": "too_big", 4 | "main_score": "TooBig" 5 | } 6 | -------------------------------------------------------------------------------- /testsuite/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.daemon=false 2 | org.gradle.console=rich 3 | -------------------------------------------------------------------------------- /testsuite/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icon-project/goloop/67f6ff8433cef57fb9785e6065f0c94b8c1a86dd/testsuite/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /testsuite/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.5.1-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /testsuite/java/foundation/icon/test/common/Codec.java: -------------------------------------------------------------------------------- 1 | package foundation.icon.test.common; 2 | 3 | import foundation.icon.ee.io.*; 4 | 5 | public abstract class Codec { 6 | abstract public DataReader newReader(byte[] bytes); 7 | abstract public DataWriter newWriter(); 8 | 9 | public static final Codec messagePack = new Codec() { 10 | @Override 11 | public DataReader newReader(byte[] bytes) { 12 | return new MessagePackDataReader(bytes); 13 | } 14 | @Override 15 | public DataWriter newWriter() { 16 | return new MessagePackDataWriter(); 17 | } 18 | }; 19 | 20 | public static final Codec rlp = new Codec() { 21 | @Override 22 | public DataReader newReader(byte[] bytes) { 23 | return new RLPNDataReader(bytes); 24 | } 25 | 26 | @Override 27 | public DataWriter newWriter() { 28 | return new RLPNDataWriter(); 29 | } 30 | }; 31 | } 32 | -------------------------------------------------------------------------------- /testsuite/java/foundation/icon/test/common/NotEnoughBalanceException.java: -------------------------------------------------------------------------------- 1 | package foundation.icon.test.common; 2 | 3 | import foundation.icon.icx.data.Address; 4 | 5 | import java.math.BigInteger; 6 | 7 | public class NotEnoughBalanceException extends Exception { 8 | public NotEnoughBalanceException() { 9 | super(); 10 | } 11 | 12 | public NotEnoughBalanceException(String message) { 13 | super(message); 14 | } 15 | 16 | public NotEnoughBalanceException(Address addr, BigInteger balance, BigInteger value) { 17 | super("Not enough balance. ID(" + addr + "), balance(" + balance + "), value(" + value + ")"); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /testsuite/java/foundation/icon/test/common/ResultTimeoutException.java: -------------------------------------------------------------------------------- 1 | package foundation.icon.test.common; 2 | 3 | import foundation.icon.icx.data.Bytes; 4 | 5 | public class ResultTimeoutException extends Exception{ 6 | Bytes txHash; 7 | 8 | public ResultTimeoutException() { 9 | super(); 10 | } 11 | 12 | public ResultTimeoutException(String message) { 13 | super(message); 14 | } 15 | 16 | public ResultTimeoutException(Bytes txHash) { 17 | super("Timeout. txHash=" + txHash); 18 | this.txHash = txHash; 19 | } 20 | 21 | public Bytes getTxHash() { 22 | return this.txHash; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /testsuite/java/foundation/icon/test/common/TransactionFailureException.java: -------------------------------------------------------------------------------- 1 | package foundation.icon.test.common; 2 | 3 | import foundation.icon.icx.data.TransactionResult; 4 | 5 | import java.math.BigInteger; 6 | 7 | public class TransactionFailureException extends Exception { 8 | private TransactionResult.Failure failure; 9 | 10 | public TransactionFailureException(TransactionResult.Failure failure) { 11 | this.failure = failure; 12 | } 13 | 14 | @Override 15 | public String toString() { 16 | return this.failure.toString(); 17 | } 18 | 19 | public BigInteger getCode() { 20 | return this.failure.getCode(); 21 | } 22 | 23 | public String getMessage() { 24 | return this.failure.getMessage(); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /testsuite/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'goloop-testsuite' 2 | include(':sdk', ':api', ':rt', ':tooling', ':samples') 3 | project(':sdk').projectDir = new File(settingsDir, '../sdk/java/library') 4 | project(':api').projectDir = new File(settingsDir, '../javaee/api') 5 | project(':rt').projectDir = new File(settingsDir, '../javaee/rt') 6 | project(':tooling').projectDir = new File(settingsDir, '../javaee/tooling') 7 | project(':samples').projectDir = new File(settingsDir, '../javaee/samples') 8 | --------------------------------------------------------------------------------