SlideShare a Scribd company logo
Java SCORE Overview
v0.6
June 2022
Why Java and the JVM?
Pros
● Reliable and mature implementation
● Strong type system
● Extensive Java tooling support
● JIT performance
● Java language popularity
● Sandbox, Sandbox, Sandbox!
Cons
● Non-deterministic operation inherently
Bytecode Instrumentation
User Code
Standard Java Class Library
SCORE API
(dummy)
Transformed
User Code
SCORE API
Java Virtual Machine
Shadow JCL
Standard Java Class Library
Bytecode
Transfor
mer
Bytecode
Optimizer
Deployment
Bytecode Instrumentation
Bytecode Optimizer
● Extracts all annotations (@External,...) and builds a APIs mapping
● Generates the body of methods tagged with @EventLog
● Removes unreachable methods
● Renames all the class, method, and field names to smaller names
(a.k.a. obfuscation) to reduce the deployment cost (optional)
Bytecode Transformer
● Checks if bytecode uses only APIs which are in whitelist
● Remaps reference to JCL classes into shadow classes
● Inserts code for charging instruction cost
● Removes ‘<clinit>’, and many other tasks...
SCORE Structure Comparison
Name Python Java
External decorator @external @External
@external(readonly=True) @External(readonly=true)
Payable decorator @payable @Payable
Eventlog decorator @eventlog @EventLog
@eventlog(indexed=1) @EventLog(indexed=1)
fallback signature def fallback(self) public void fallback()
SCORE initialize override on_install(...) method define a public constructor
Default parameters native language support @Optional
SCORE APIs Comparison
Python Java Description
self.address Context.getAddress() The current SCORE address
self.block.height Context.getBlockHeight() The current block height
self.msg.sender Context.getCaller() The address of the account who called this
function
self.tx.hash Context.getTransactionHash() The transaction hash
self.icx.transfer() Context.transfer() ICX transfer function
revert() Context.revert() Reverts the transaction and breaks
create_address_with_key() Context.getAddressFromKey() Returns the address that is associated with the
given public key
Component Diagram
Transaction
Executor
Transaction &
Result Manager
Contract
Handler
Transfer
Handler
External
Handler
Python
Executor
JavaEE Manager
IPC
Python
Executor
Python
Executor
Python
Execut
or
Python
Execut
or
Java
Executor
Invoking a external method of other SCOREs
● Use Context.call()
// [package score.Context]
public static Object call(Address targetAddress, String method,
Object… params);
public static Object call(BigInteger value, Address targetAddress,
String method, Object… params);
// Example
if (_to.isContract()) {
Context.call(_to, “tokenFallback”, _from, _value, dataBytes);
}
Error Handling
● Uncatchable exceptions
○ Non-deterministic system errors (eg. OOM or I/O errors)
■ shall not be visible to SCORE (uncatchable), otherwise SCORE’s
behavior may depend on the error.
○ Deterministic, but shall not be catchable
■ OutOfStep, StackOverflow
● Catchable exceptions
○ IllegalArgumentException
■ {Contract|Method}NotFound, OutOfBalance, InvalidParameter, etc
○ ScoreRevertException
■ Caused by Context.revert()
Support List/Map return types in @External method
● Provide List.of() and Map.of()
○ Convenience static factory methods for creating unmodifiable instances
○ JEP 269: Convenience Factory Methods for Collections
○ Fully compliant with the existing Python SCOREs
@External(readonly=true)
public List<Address> getConfirmations(BigInteger _transactionId) {
...
Address[] confirmations = new Address[count];
...
return List.of(confirmations);
}
Storage Model
Object Graph
● Serializes all live objects that are reachable from static roots
● Provides an illusion like this:
○ A program starts and then runs forever.
● Cons: inefficient as it must be stored as a whole even if it is partially changed
Key-Value Storage
● Supports same interfaces as Python SCORE does
○ VarDB, ArrayDB and DictDB
Object Graph
Variable DB
// VarDB<BigInteger> counter = ...
var counter = Context.newVarDB("counter", BigInteger.class);
counter.set(BigInteger.ZERO);
counter.set(counter.get().add(BigInteger.ONE));
Array DB
// ArrayDB<Address> addrList = ...
var addrList = Context.newArrayDB("addrList", Address.class);
addrList.add(Context.getAddress());
Context.require(addrList.size() == 1);
Context.require(addrList.get(0).equals(Context.getAddress()));
addrList.set(0, Context.getOwner());
Context.require(addrList.get(0).equals(Context.getOwner()));
Dictionary DB
DictDB<Address, BigInteger> balances
= Context.newDictDB("balances", BigInteger.class);
var balance = BigInteger.valueOf(1_000_000);
balances.set(Context.getOwner(), balance);
Context.require(balances.get(Context.getOwner()).equals(balance));
Branch DB
● A branch DB behaves as branches to sub-DBs
BranchDB<BigInteger, DictDB<Address, Boolean>> confirmations
= Context.newBranchDB("confirmations", Boolean.class);
var txID = BigInteger.ZERO;
confirmations.at(txID).set(Context.getCaller(), true);
Context.require(confirmations.at(txID).get(Context.getCaller()));
Object Serialization in DB (1)
● A DB can store an object of a CustomClass, if the class implements the
following codec methods.
public static void writeObject(ObjectWriter w, CustomClass v) {
...
}
public static CustomClass readObject(ObjectReader r) {
...
}
public class Transaction {
public static void writeObject(ObjectWriter w, Transaction t) {
w.writeListOf(t.from, t.to, t.value);
}
public static Transaction readObject(ObjectReader r) {
r.beginList();
Transaction t = new Transaction(
r.read(Address.class),
r.read(Address.class),
r.read(BigInteger.class)
);
r.end();
return t;
}
}
Object Serialization in DB (2)
Object Serialization in DB (3)
DictDB<BigInteger, Transaction> transactions
= Context.newDictDB("transactions", Transaction.class);
var tx1 = new Transaction(
Context.getOrigin(),
Context.getOwner(),
BigInteger.valueOf(1_000_000)
);
transactions.set(BigInteger.valueOf(1), tx1);
var tx2 = transactions.get(BigInteger.valueOf(1));
Context.require(tx1.equals(tx2));
References
● SCORE API document
○ https://www.javadoc.io/doc/foundation.icon/javaee-api
● gradle-javaee-plugin project
○ https://github.com/icon-project/gradle-javaee-plugin
● Java SCORE examples project
○ https://github.com/icon-project/java-score-examples
● javaee project
○ https://github.com/icon-project/goloop/tree/master/javaee
● goloop CLI commands
○ https://github.com/icon-project/goloop/blob/master/doc/goloop_cli.md

More Related Content

Similar to Core2 Document - Java SCORE Overview.pptx.pdf

Spring framework part 2
Spring framework part 2Spring framework part 2
Spring framework part 2
Haroon Idrees
 
React native
React nativeReact native
React native
Vishal Dubey
 
Applying Compiler Techniques to Iterate At Blazing Speed
Applying Compiler Techniques to Iterate At Blazing SpeedApplying Compiler Techniques to Iterate At Blazing Speed
Applying Compiler Techniques to Iterate At Blazing Speed
Pascal-Louis Perez
 
Apache Spark in your likeness - low and high level customization
Apache Spark in your likeness - low and high level customizationApache Spark in your likeness - low and high level customization
Apache Spark in your likeness - low and high level customization
Bartosz Konieczny
 
Domain-Driven Design with SeedStack
Domain-Driven Design with SeedStackDomain-Driven Design with SeedStack
Domain-Driven Design with SeedStack
SeedStack
 
Powerful persistence layer with Google Guice & MyBatis
Powerful persistence layer with Google Guice & MyBatisPowerful persistence layer with Google Guice & MyBatis
Powerful persistence layer with Google Guice & MyBatissimonetripodi
 
Domain Driven Design Tactical Patterns
Domain Driven Design Tactical PatternsDomain Driven Design Tactical Patterns
Domain Driven Design Tactical Patterns
Robert Alexe
 
Evolving a Clean, Pragmatic Architecture at JBCNConf 2019
Evolving a Clean, Pragmatic Architecture at JBCNConf 2019Evolving a Clean, Pragmatic Architecture at JBCNConf 2019
Evolving a Clean, Pragmatic Architecture at JBCNConf 2019
Victor Rentea
 
Spring Day | Spring and Scala | Eberhard Wolff
Spring Day | Spring and Scala | Eberhard WolffSpring Day | Spring and Scala | Eberhard Wolff
Spring Day | Spring and Scala | Eberhard Wolff
JAX London
 
ADG Poznań - Kotlin for Android developers
ADG Poznań - Kotlin for Android developersADG Poznań - Kotlin for Android developers
ADG Poznań - Kotlin for Android developers
Bartosz Kosarzycki
 
Functional, Type-safe, Testable Microservices with ZIO and gRPC
Functional, Type-safe, Testable Microservices with ZIO and gRPCFunctional, Type-safe, Testable Microservices with ZIO and gRPC
Functional, Type-safe, Testable Microservices with ZIO and gRPC
Nadav Samet
 
Daggerate your code - Write your own annotation processor
Daggerate your code - Write your own annotation processorDaggerate your code - Write your own annotation processor
Daggerate your code - Write your own annotation processor
Bartosz Kosarzycki
 
Uncommon Design Patterns
Uncommon Design PatternsUncommon Design Patterns
Uncommon Design Patterns
Stefano Fago
 
Apache Spark, the Next Generation Cluster Computing
Apache Spark, the Next Generation Cluster ComputingApache Spark, the Next Generation Cluster Computing
Apache Spark, the Next Generation Cluster Computing
Gerger
 
Spark SQL Catalyst Code Optimization using Function Outlining with Kavana Bha...
Spark SQL Catalyst Code Optimization using Function Outlining with Kavana Bha...Spark SQL Catalyst Code Optimization using Function Outlining with Kavana Bha...
Spark SQL Catalyst Code Optimization using Function Outlining with Kavana Bha...
Databricks
 
Interpreter Case Study - Design Patterns
Interpreter Case Study - Design PatternsInterpreter Case Study - Design Patterns
Interpreter Case Study - Design Patterns
CodeOps Technologies LLP
 
Eclipse Day India 2015 - Java 8 Overview
Eclipse Day India 2015 - Java 8 OverviewEclipse Day India 2015 - Java 8 Overview
Eclipse Day India 2015 - Java 8 Overview
Eclipse Day India
 
Oleksandr Valetskyy - DI vs. IoC
Oleksandr Valetskyy - DI vs. IoCOleksandr Valetskyy - DI vs. IoC
Oleksandr Valetskyy - DI vs. IoC
Oleksandr Valetskyy
 
Hadoop Integration in Cassandra
Hadoop Integration in CassandraHadoop Integration in Cassandra
Hadoop Integration in Cassandra
Jairam Chandar
 
Scala is java8.next()
Scala is java8.next()Scala is java8.next()
Scala is java8.next()
daewon jeong
 

Similar to Core2 Document - Java SCORE Overview.pptx.pdf (20)

Spring framework part 2
Spring framework part 2Spring framework part 2
Spring framework part 2
 
React native
React nativeReact native
React native
 
Applying Compiler Techniques to Iterate At Blazing Speed
Applying Compiler Techniques to Iterate At Blazing SpeedApplying Compiler Techniques to Iterate At Blazing Speed
Applying Compiler Techniques to Iterate At Blazing Speed
 
Apache Spark in your likeness - low and high level customization
Apache Spark in your likeness - low and high level customizationApache Spark in your likeness - low and high level customization
Apache Spark in your likeness - low and high level customization
 
Domain-Driven Design with SeedStack
Domain-Driven Design with SeedStackDomain-Driven Design with SeedStack
Domain-Driven Design with SeedStack
 
Powerful persistence layer with Google Guice & MyBatis
Powerful persistence layer with Google Guice & MyBatisPowerful persistence layer with Google Guice & MyBatis
Powerful persistence layer with Google Guice & MyBatis
 
Domain Driven Design Tactical Patterns
Domain Driven Design Tactical PatternsDomain Driven Design Tactical Patterns
Domain Driven Design Tactical Patterns
 
Evolving a Clean, Pragmatic Architecture at JBCNConf 2019
Evolving a Clean, Pragmatic Architecture at JBCNConf 2019Evolving a Clean, Pragmatic Architecture at JBCNConf 2019
Evolving a Clean, Pragmatic Architecture at JBCNConf 2019
 
Spring Day | Spring and Scala | Eberhard Wolff
Spring Day | Spring and Scala | Eberhard WolffSpring Day | Spring and Scala | Eberhard Wolff
Spring Day | Spring and Scala | Eberhard Wolff
 
ADG Poznań - Kotlin for Android developers
ADG Poznań - Kotlin for Android developersADG Poznań - Kotlin for Android developers
ADG Poznań - Kotlin for Android developers
 
Functional, Type-safe, Testable Microservices with ZIO and gRPC
Functional, Type-safe, Testable Microservices with ZIO and gRPCFunctional, Type-safe, Testable Microservices with ZIO and gRPC
Functional, Type-safe, Testable Microservices with ZIO and gRPC
 
Daggerate your code - Write your own annotation processor
Daggerate your code - Write your own annotation processorDaggerate your code - Write your own annotation processor
Daggerate your code - Write your own annotation processor
 
Uncommon Design Patterns
Uncommon Design PatternsUncommon Design Patterns
Uncommon Design Patterns
 
Apache Spark, the Next Generation Cluster Computing
Apache Spark, the Next Generation Cluster ComputingApache Spark, the Next Generation Cluster Computing
Apache Spark, the Next Generation Cluster Computing
 
Spark SQL Catalyst Code Optimization using Function Outlining with Kavana Bha...
Spark SQL Catalyst Code Optimization using Function Outlining with Kavana Bha...Spark SQL Catalyst Code Optimization using Function Outlining with Kavana Bha...
Spark SQL Catalyst Code Optimization using Function Outlining with Kavana Bha...
 
Interpreter Case Study - Design Patterns
Interpreter Case Study - Design PatternsInterpreter Case Study - Design Patterns
Interpreter Case Study - Design Patterns
 
Eclipse Day India 2015 - Java 8 Overview
Eclipse Day India 2015 - Java 8 OverviewEclipse Day India 2015 - Java 8 Overview
Eclipse Day India 2015 - Java 8 Overview
 
Oleksandr Valetskyy - DI vs. IoC
Oleksandr Valetskyy - DI vs. IoCOleksandr Valetskyy - DI vs. IoC
Oleksandr Valetskyy - DI vs. IoC
 
Hadoop Integration in Cassandra
Hadoop Integration in CassandraHadoop Integration in Cassandra
Hadoop Integration in Cassandra
 
Scala is java8.next()
Scala is java8.next()Scala is java8.next()
Scala is java8.next()
 

Recently uploaded

Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Product School
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
RTTS
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Product School
 
Generating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using SmithyGenerating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using Smithy
g2nightmarescribd
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
Product School
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Product School
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
Paul Groth
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
Frank van Harmelen
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
Product School
 

Recently uploaded (20)

Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
Generating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using SmithyGenerating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using Smithy
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 

Core2 Document - Java SCORE Overview.pptx.pdf

  • 2. Why Java and the JVM? Pros ● Reliable and mature implementation ● Strong type system ● Extensive Java tooling support ● JIT performance ● Java language popularity ● Sandbox, Sandbox, Sandbox! Cons ● Non-deterministic operation inherently
  • 3. Bytecode Instrumentation User Code Standard Java Class Library SCORE API (dummy) Transformed User Code SCORE API Java Virtual Machine Shadow JCL Standard Java Class Library Bytecode Transfor mer Bytecode Optimizer Deployment
  • 4. Bytecode Instrumentation Bytecode Optimizer ● Extracts all annotations (@External,...) and builds a APIs mapping ● Generates the body of methods tagged with @EventLog ● Removes unreachable methods ● Renames all the class, method, and field names to smaller names (a.k.a. obfuscation) to reduce the deployment cost (optional) Bytecode Transformer ● Checks if bytecode uses only APIs which are in whitelist ● Remaps reference to JCL classes into shadow classes ● Inserts code for charging instruction cost ● Removes ‘<clinit>’, and many other tasks...
  • 5. SCORE Structure Comparison Name Python Java External decorator @external @External @external(readonly=True) @External(readonly=true) Payable decorator @payable @Payable Eventlog decorator @eventlog @EventLog @eventlog(indexed=1) @EventLog(indexed=1) fallback signature def fallback(self) public void fallback() SCORE initialize override on_install(...) method define a public constructor Default parameters native language support @Optional
  • 6. SCORE APIs Comparison Python Java Description self.address Context.getAddress() The current SCORE address self.block.height Context.getBlockHeight() The current block height self.msg.sender Context.getCaller() The address of the account who called this function self.tx.hash Context.getTransactionHash() The transaction hash self.icx.transfer() Context.transfer() ICX transfer function revert() Context.revert() Reverts the transaction and breaks create_address_with_key() Context.getAddressFromKey() Returns the address that is associated with the given public key
  • 7. Component Diagram Transaction Executor Transaction & Result Manager Contract Handler Transfer Handler External Handler Python Executor JavaEE Manager IPC Python Executor Python Executor Python Execut or Python Execut or Java Executor
  • 8. Invoking a external method of other SCOREs ● Use Context.call() // [package score.Context] public static Object call(Address targetAddress, String method, Object… params); public static Object call(BigInteger value, Address targetAddress, String method, Object… params); // Example if (_to.isContract()) { Context.call(_to, “tokenFallback”, _from, _value, dataBytes); }
  • 9. Error Handling ● Uncatchable exceptions ○ Non-deterministic system errors (eg. OOM or I/O errors) ■ shall not be visible to SCORE (uncatchable), otherwise SCORE’s behavior may depend on the error. ○ Deterministic, but shall not be catchable ■ OutOfStep, StackOverflow ● Catchable exceptions ○ IllegalArgumentException ■ {Contract|Method}NotFound, OutOfBalance, InvalidParameter, etc ○ ScoreRevertException ■ Caused by Context.revert()
  • 10. Support List/Map return types in @External method ● Provide List.of() and Map.of() ○ Convenience static factory methods for creating unmodifiable instances ○ JEP 269: Convenience Factory Methods for Collections ○ Fully compliant with the existing Python SCOREs @External(readonly=true) public List<Address> getConfirmations(BigInteger _transactionId) { ... Address[] confirmations = new Address[count]; ... return List.of(confirmations); }
  • 11. Storage Model Object Graph ● Serializes all live objects that are reachable from static roots ● Provides an illusion like this: ○ A program starts and then runs forever. ● Cons: inefficient as it must be stored as a whole even if it is partially changed Key-Value Storage ● Supports same interfaces as Python SCORE does ○ VarDB, ArrayDB and DictDB
  • 13. Variable DB // VarDB<BigInteger> counter = ... var counter = Context.newVarDB("counter", BigInteger.class); counter.set(BigInteger.ZERO); counter.set(counter.get().add(BigInteger.ONE));
  • 14. Array DB // ArrayDB<Address> addrList = ... var addrList = Context.newArrayDB("addrList", Address.class); addrList.add(Context.getAddress()); Context.require(addrList.size() == 1); Context.require(addrList.get(0).equals(Context.getAddress())); addrList.set(0, Context.getOwner()); Context.require(addrList.get(0).equals(Context.getOwner()));
  • 15. Dictionary DB DictDB<Address, BigInteger> balances = Context.newDictDB("balances", BigInteger.class); var balance = BigInteger.valueOf(1_000_000); balances.set(Context.getOwner(), balance); Context.require(balances.get(Context.getOwner()).equals(balance));
  • 16. Branch DB ● A branch DB behaves as branches to sub-DBs BranchDB<BigInteger, DictDB<Address, Boolean>> confirmations = Context.newBranchDB("confirmations", Boolean.class); var txID = BigInteger.ZERO; confirmations.at(txID).set(Context.getCaller(), true); Context.require(confirmations.at(txID).get(Context.getCaller()));
  • 17. Object Serialization in DB (1) ● A DB can store an object of a CustomClass, if the class implements the following codec methods. public static void writeObject(ObjectWriter w, CustomClass v) { ... } public static CustomClass readObject(ObjectReader r) { ... }
  • 18. public class Transaction { public static void writeObject(ObjectWriter w, Transaction t) { w.writeListOf(t.from, t.to, t.value); } public static Transaction readObject(ObjectReader r) { r.beginList(); Transaction t = new Transaction( r.read(Address.class), r.read(Address.class), r.read(BigInteger.class) ); r.end(); return t; } } Object Serialization in DB (2)
  • 19. Object Serialization in DB (3) DictDB<BigInteger, Transaction> transactions = Context.newDictDB("transactions", Transaction.class); var tx1 = new Transaction( Context.getOrigin(), Context.getOwner(), BigInteger.valueOf(1_000_000) ); transactions.set(BigInteger.valueOf(1), tx1); var tx2 = transactions.get(BigInteger.valueOf(1)); Context.require(tx1.equals(tx2));
  • 20. References ● SCORE API document ○ https://www.javadoc.io/doc/foundation.icon/javaee-api ● gradle-javaee-plugin project ○ https://github.com/icon-project/gradle-javaee-plugin ● Java SCORE examples project ○ https://github.com/icon-project/java-score-examples ● javaee project ○ https://github.com/icon-project/goloop/tree/master/javaee ● goloop CLI commands ○ https://github.com/icon-project/goloop/blob/master/doc/goloop_cli.md