API:
Added sample AT-emitted transaction types (payment/message).
Maximum number of steps per execution round no longer hard-coded.
API.putTransactionAfterTimestampInA() sets A to zero if no more transactions.
API.putMessageFromTransactionInAIntoB sets B to zero if not a message transaction.
Added some convenience methods.
MachineState:
Added support for minimum activation amount.
Added static method for packing AT into "creation bytes".
No need to store unchanging code in per-height AT state data.
Added support for multiple blockchains to "Timestamp".
General improvements based on Sonarlint suggestions.
General improvements to comments.
Replaced deprecated Byte/Short/Integer/Long constructor call with corresponding .valueOf() call.
Replaced some string concatenations with StringBuilder.
Moved Java-related .gitignore from root to /Java/
Removed .classpath and .project, and added same to .gitignore
Added info on how to add CIYAM AT JAR to other projects.
Updated pom.xml:
Bumped version to 1.2
Bumped Java version from 1.8 to 11
Bumped BouncyCastle from 1.60 to 1.64
Added more tests.
Two new API calls:
getOpCodeSteps(OpCode) : int
getFeePerStep() : long
This allows API to determine cost per "step" and charge more for (say) function opcodes.
MachineState knows the balance at the end of each execution round,
so now AT's previousBalance is managed by MachineState and added to serialized data.
API calls payCurrentBalanceToB and payPreviousBalanceToB are absorbed into payAmountToB,
and amounts passed are calculated by FunctionCode instead.
Added API call onFinished(long amount, MachineState state) for when AT has finished
so API can return remaining funds (amount) to creator.
Added API call isFirstOpCodeAfterSleeping() : boolean to replace dodgy test of
state.getSteps() == 0 in getRandomUsingTransactionInA().
The API call getCurrentBalance is now used by MachineState to find out AT's balance
at the beginning of execution round. After this, MachineState manages the balance until
the end of execution, whereby the caller can find out the new balance from MachineState.
Corrected some code in FunctionCode to get current balance from MachineState instead in
light of above. (Ditto previousBalance).
Added MAX_STEPS to MachineState to ATs can be made to sleep if they execute too many
steps in one execution round.
Added some pre-execution checks to MachineState.execute() to prevent execution in some
cases, like already finished, or not enough balance to un-freeze, or not reached
required block while sleeping, etc.
Unit tests pass, but there are no test for new steps/fee code yet!
API is now an abstract class instead of an Interface. This is to
allow protected methods that give access to package-scoped methods
and variables inside MachineState.
MachineState now supports a different set of constants based on AT
version.
MachineState's methods and variables have had their scopes tightened
up and getters/setters added where appropriate.
MachineState.parseHeader() inlined into the constructor that calls it
so it can set public final variables.
Some reordering and additional comments in MachineState.
OpCode enum entries refactored so that:
a) variables provided via MachineState "state" are not explicitly
passed as well
b) args to each opcode are pre-fetched from the codeByteBuffer before
calling and only need to be cast before use. this comes almost
"for free" thanks to OpCodeParam.fetch
Calling functions from OpCode now cleaner as there's no write-access
to programCounter, only changing codeByteBuffer's position.
Also in OpCode, state.getProgramCounter() now provides a consistent
before-opcode position for branches, jumps, etc.
Lots of repeated code refactored out of unit tests into ExecutableTest
class. ExecutableTest also provides helper methods for examining
post-execution data values, stack positions and entries.