Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
117 commits
Select commit Hold shift + click to select a range
7ac2d98
Add xgtvm to xgt
shiftreset Jul 12, 2021
7a2b2ca
Add xgtvm to xgt
shiftreset Jul 12, 2021
b4342fc
Adding machine api
dateclubsoda Jul 13, 2021
6fb2d48
Adding plugins to rakefile
dateclubsoda Jul 13, 2021
b5837f4
Committing changes to cmakelists for chain-tests
dateclubsoda Jul 14, 2021
0dc52fa
adding graphene and xgtvm to witness cmakelists
liamnoroian Jul 19, 2021
71f1d7d
Busting through errors to build machine_api
liamnoroian Jul 19, 2021
632edbf
Revert "Busting through errors to build machine_api"
liamnoroian Jul 20, 2021
06ea7db
Integrate chain adapter
shiftreset Jul 22, 2021
7e918af
Merge pull request #77 from xgt-network/chain-adapter-2
Jul 22, 2021
63d1ddc
Merge branch 'xgtvm-integration' of https://github.com/xgt-network/xg…
liamnoroian Jul 22, 2021
e8fe352
Setting up contract invocation
liamnoroian Jul 22, 2021
4b126ff
Adding placeholder wallet to rakefile
liamnoroian Jul 22, 2021
490c5de
Do not immediately reject peers with bad blocks
shiftreset Jul 31, 2021
144f3d7
api: include human readable version string
raggi Aug 6, 2021
c3769c1
Merge pull request #99 from xgt-network/master
obskein Aug 6, 2021
6ba9122
Merge pull request #98 from raggi/versions
obskein Aug 6, 2021
685370f
Merge pull request #94 from xgt-network/keep-sometimes-bad-peers
obskein Aug 6, 2021
bbaeae1
Merge branch 'edge-client' of github.com:xgt-network/xgt into xgtvm-i…
shiftreset Aug 12, 2021
6dbfd94
Fix merge
shiftreset Aug 12, 2021
33f5aeb
Merge branch 'xgtvm-integration' of https://github.com/xgt-network/xg…
liamnoroian Aug 13, 2021
f7739b6
Pulling recent changes
liamnoroian Aug 13, 2021
ce9270c
Removing random piece of code
liamnoroian Aug 13, 2021
653dea3
Remove diff artifacts
shiftreset Aug 16, 2021
5179f9d
Get building
shiftreset Aug 16, 2021
6e56ca0
Add a debug invoke task to Rakefile
shiftreset Aug 17, 2021
b2bdf97
Allow starting from genesis using a command-line flag
shiftreset Aug 17, 2021
77448ad
adding to_big_word type, reformatting stack variant accessors
liamnoroian Aug 18, 2021
2cf3b16
Fixing build issues in vendored machine
liamnoroian Aug 18, 2021
5936e5e
Updating adapter methods
liamnoroian Aug 18, 2021
b11acfe
Link keccak library
shiftreset Aug 20, 2021
4b8b63b
Merge branch 'from-genesis' into xgtvm-integration
shiftreset Aug 20, 2021
b1aa770
Merge branch 'xgtvm-keccak' into xgtvm-integration
shiftreset Aug 25, 2021
d2e36d7
Working hashing
shiftreset Aug 25, 2021
9bd932f
Add keccak to chain
shiftreset Aug 26, 2021
4d8f973
Add keccak to chain
shiftreset Aug 26, 2021
fbe993a
Merge branch 'xgtvm-integration' of github.com:xgt-network/xgt into x…
shiftreset Aug 27, 2021
e430fae
Continue to integrate xgtvm with chain
shiftreset Aug 27, 2021
8974e83
WIP
liamnoroian Aug 30, 2021
ac164a4
Merge branch 'xgtvm-integration' of github.com:xgt-network/xgt into x…
liamnoroian Aug 30, 2021
011cf26
WIP
liamnoroian Aug 30, 2021
eaf2773
WIP
liamnoroian Aug 30, 2021
f490df3
WIP
liamnoroian Aug 30, 2021
1993fd7
adding back get_balance
liamnoroian Aug 30, 2021
065b077
Adding get_balance to xgt_evaluator
liamnoroian Aug 30, 2021
c46df76
WIP outlining adapter methods
liamnoroian Aug 30, 2021
40a384d
Adding descriptions of remaining adapter methods
liamnoroian Aug 31, 2021
b91fdd4
Fix build
shiftreset Aug 31, 2021
5bd9852
Merge branch 'xgtvm-integration' of github.com:xgt-network/xgt into x…
shiftreset Aug 31, 2021
67023fa
Expanding adapter methods
liamnoroian Aug 31, 2021
a511331
Adding utility function for block hashing, updating adapter methods
liamnoroian Aug 31, 2021
61a72e9
Clean up some errors
shiftreset Sep 2, 2021
be82f83
Fix errors
shiftreset Sep 2, 2021
427ac36
Implement get_block_hash
liamnoroian Sep 2, 2021
6fb2dc6
Build out more invocation
shiftreset Sep 8, 2021
1f04178
Merge branch 'xgtvm-integration' of github.com:xgt-network/xgt into x…
shiftreset Sep 8, 2021
5ad73cc
Adding get_contract_at_addr
liamnoroian Sep 8, 2021
1524dd5
Merge branch 'xgtvm-integration' of github.com:xgt-network/xgt into x…
shiftreset Sep 8, 2021
d1a8dd2
Integration work
shiftreset Sep 8, 2021
bd6a29a
Remove machine from contract_api for now
shiftreset Sep 10, 2021
15afd6b
Invoke
shiftreset Sep 14, 2021
944eeb0
Fix error
shiftreset Sep 14, 2021
cd10bb0
Fix contract_api
shiftreset Sep 15, 2021
fe39ab9
Create, list, and query contracts
shiftreset Sep 16, 2021
c67c01d
rake contracts:create end-to-end
shiftreset Sep 16, 2021
a97e9fa
Last minute tweaks
shiftreset Sep 17, 2021
515695a
vendor in xgtvm changes
liamnoroian Sep 17, 2021
228cedf
Fix uniqueness issue
shiftreset Sep 22, 2021
0d8d1dc
Merge branch 'xgtvm-integration' of github.com:xgt-network/xgt into x…
shiftreset Sep 22, 2021
830cffa
Bring back contract log objects
shiftreset Sep 22, 2021
1c97214
Add emit_log, use address for get_code_at_addr
liamnoroian Sep 23, 2021
0a22f24
Adding emit_log, revising log_object
liamnoroian Sep 24, 2021
55e9fef
Fix build error
Sep 28, 2021
6696754
Remove wallet field from contract (use owner instead)
shiftreset Sep 30, 2021
2b7060d
Finish log operations
shiftreset Oct 1, 2021
855bde4
LOAD and SSTORE
shiftreset Oct 1, 2021
9be6ec9
Adding energy_interval and energy_multiplier
liamnoroian Oct 14, 2021
d59af36
Contract invoke stuff
shiftreset Oct 21, 2021
2e46d9a
Adding energy map
liamnoroian Oct 21, 2021
c8a9663
Vendor updated xgtvm
liamnoroian Oct 25, 2021
9759f57
WIP: pack and unpack uiint256_t
shiftreset Oct 29, 2021
a438b54
Storage adapter methods
shiftreset Nov 1, 2021
e4d48fd
Invocation, storage, and return
shiftreset Nov 2, 2021
3003246
Merge branch 'xgtvm-integration' into energy
liamnoroian Nov 3, 2021
281d04b
Fix blocks not pushing issue
shiftreset Nov 3, 2021
25f6b0d
Add "Do Nothing" test contract
shiftreset Nov 4, 2021
933ae00
updating energy regeneration
liamnoroian Nov 8, 2021
71fc084
removing unnecessary logging
liamnoroian Nov 11, 2021
fc5a1b6
Updating formatting
liamnoroian Nov 15, 2021
35dd084
Merging in xgtvm branch
liamnoroian Nov 15, 2021
b1d6fca
Consolidate contract invoke calls
shiftreset Nov 15, 2021
5d32c2b
Add bytecode examples
shiftreset Nov 15, 2021
8f40177
merging in new changes from xgtvm / contract templates
liamnoroian Nov 15, 2021
1fb531a
updating xgt evaluator
liamnoroian Nov 15, 2021
010469d
Fixing contract storage db creation
liamnoroian Nov 16, 2021
c4fca64
Smart contract invokation
liamnoroian Dec 5, 2021
3b86400
Smart contract invocation
liamnoroian Dec 5, 2021
82a56be
Merge branch 'merge-xgtvm' of github.com:xgt-network/xgt into merge-x…
liamnoroian Dec 5, 2021
3a0e52e
WIP handle contract preamble
liamnoroian Dec 6, 2021
d9d17cd
Ripemd160 address type indexing
liamnoroian Dec 7, 2021
5897f22
Adding wallet lookup by ripemd160 address
liamnoroian Dec 8, 2021
1133aaf
Adding ripemd160 utilities
liamnoroian Jan 6, 2022
0d636a6
Adding helper methods to retrieve wallets
liamnoroian Jan 6, 2022
6a8c9b6
Updating contract object to query for associated wallet address
liamnoroian Jan 6, 2022
367c707
Begin implementation of vm call methods
liamnoroian Jan 6, 2022
6776ee6
Refactor rakefile, update call, staticcall, delegatecall
liamnoroian Jan 18, 2022
fc90991
WIP Create2
liamnoroian Apr 5, 2022
07bac19
init code hash returning correct value
liamnoroian Apr 11, 2022
284d659
add xgtvm typing system
liamnoroian Apr 15, 2022
49cd77f
Clean up todos
liamnoroian Apr 15, 2022
2fa58a3
Clean up old files
liamnoroian Apr 18, 2022
579d774
Bring in rlpvalue
liamnoroian Apr 18, 2022
5906138
Changes chain id when in testnet
liamnoroian Apr 25, 2022
a162964
Configure testnet env
liamnoroian Apr 26, 2022
3c723c9
Reset rakefile config, hardcode init_public_key for init miner
liamnoroian Apr 26, 2022
c0a7fdf
Remove output
liamnoroian Apr 26, 2022
68fd8e9
Resolve merge conflict
liamnoroian Sep 30, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .vimrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
set tabstop=3
set expandtab
set shiftwidth=3
"set autoindent
"set smartindent
"set cindent
315 changes: 92 additions & 223 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ require 'json'
require 'bigdecimal'
require 'shellwords'
require 'rake/testtask'
import 'tasks/contracts.rake'
import 'tasks/lazy_wallets.rake'
autoload :Xgt, 'xgt/ruby'
autoload :Etc, 'etc'

Expand All @@ -19,8 +21,12 @@ end

directory "../xgt-build"

def from_genesis?
ENV['FROM_GENESIS']&.upcase == 'TRUE'
end

def mining_disabled?
ENV['MINING_DISABLED']&.upcase == 'TRUE'
ENV['MINING_DISABLED']&.upcase == 'FALSE'
end

def mining_threads
Expand Down Expand Up @@ -74,6 +80,10 @@ def instance_index
ENV['XGT_INSTANCE_INDEX'].to_i
end

def port_offset
ENV['XGT_PORT_OFFSET'].to_i
end

def config
rpc.call('database_api.get_config', {})
end
Expand Down Expand Up @@ -114,7 +124,12 @@ end

desc 'Runs CMake to prepare the project'
task :configure => "../xgt-build" do
sh %( cmake -G Ninja -B ../xgt-build -S . -D CMAKE_BUILD_TYPE=RelWithDebInfo )
sh %( cmake -G Ninja -B ../xgt-build -S . -D CMAKE_BUILD_TYPE=debug )
end

desc 'Runs CMake to prepare the project for testnet'
task :configure_testnet => "../xgt-build" do
sh %( cmake -G Ninja -B ../xgt-build -S . -D CMAKE_BUILD_TYPE=debug -D BUILD_XGT_TESTNET=ON )
end

task :test do
Expand Down Expand Up @@ -280,8 +295,8 @@ task :run do

shared-file-size = 12G

p2p-endpoint = #{my_host}:#{2001 + instance_index}
webserver-http-endpoint = #{my_host}:#{8751 + instance_index * 2}
p2p-endpoint = #{my_host}:#{2001 + port_offset + instance_index}
webserver-http-endpoint = #{my_host}:#{8751 + port_offset + instance_index * 2}

miner = ["#{wallet}","#{wif}"]
mining-threads = #{mining_threads}
Expand All @@ -291,251 +306,105 @@ task :run do

enable-stale-production = #{mining_disabled? ? 'false' : 'true'}
)))
if seed_hosts && seed_hosts.any?
if from_genesis?
f.puts "p2p-seed-node = "
elsif seed_hosts && seed_hosts.any?
f.puts "p2p-seed-node = #{seed_hosts.join(" ")}"
end
f.puts "p2p-seed-node = "
end
$stderr.puts(File.read("#{data_dir}/config.ini"))

sh %(cd #{data_dir} && ../xgt-build/programs/xgtd/xgtd --data-dir=.)
flags = ['--data-dir=.']
if from_genesis?
flags << '--from-genesis'
end
sh %(cd #{data_dir} && ../xgt-build/programs/xgtd/xgtd #{flags.join(' ')})
end

desc 'Get approximate C++ LoC'
task :wc do
sh %(wc -l #{Dir.glob('**/*.{c,h}pp').join(' ')})
end

namespace :lazy_wallets do
task :name_test do
generate_keys = ->() {
master = Xgt::Ruby::Auth.random_wif
ks = { 'master' => master }
%w(recovery money social memo).each do |role|
private_key = Xgt::Ruby::Auth.generate_wif(wallet, master, 'recovery')
public_key = Xgt::Ruby::Auth.wif_to_public_key(private_key, address_prefix)
ks["#{role}_private"] = private_key
ks["#{role}_public"] = public_key
end
ks
}

master = Xgt::Ruby::Auth.random_wif
def generate_keys
master = Xgt::Ruby::Auth.random_wif
ks = { 'master' => master }
%w(recovery money social memo).each do |role|
private_key = Xgt::Ruby::Auth.generate_wif(wallet, master, 'recovery')
public_key = Xgt::Ruby::Auth.wif_to_public_key(private_key, address_prefix)

response = rpc.call('wallet_by_key_api.generate_wallet_name', {
'recovery_keys' => [public_key]
})
wallet_name = response['wallet_name']

txn = {
'extensions' => [],
'operations' => [
{
'type' => 'transfer_operation',
'value' => {
'amount' => {
'amount' => '1',
'precision' => 8,
'nai' => '@@000000021'
},
'from' => 'XGT0000000000000000000000000000000000000000',
'to' => wallet_name,
'json_metadata' => '',
'extensions' => []
}
}
]
}

id = rpc.broadcast_transaction(txn, [wif], chain_id)
(puts 'Waiting...' or sleep 1) until rpc.transaction_ready?(id)

keys = generate_keys.call
txn = {
'extensions' => [],
'operations' => [
{
'type' => 'wallet_update_operation',
'value' => {
'wallet' => wallet_name,
'recovery' => {
'weight_threshold' => 1,
'account_auths' => [],
'key_auths' => [[keys['recovery_public'], 1]]
},
'money' => {
'weight_threshold' => 1,
'account_auths' => [],
'key_auths' => [[keys['money_public'], 1]]
},
'social' => {
'weight_threshold' => 1,
'account_auths' => [],
'key_auths' => [[keys['social_public'], 1]]
},
'memo_key' => keys['memo_public'],
'json_metadata' => '',
'extensions' => []
}
}
]
}

p txn
id = rpc.broadcast_transaction(txn, [private_key], chain_id)
(puts 'Waiting...' or sleep 1) until rpc.transaction_ready?(id)
ks["#{role}_private"] = private_key
ks["#{role}_public"] = public_key
end
end

namespace :catalyst do
generate_keys = ->() {
FileUtils.mkdir_p('out')
File.open('out/keys.json', 'w') do |f|
master = Xgt::Ruby::Auth.random_wif
ks = { 'master' => master }
%w(recovery money social memo witness).each do |role|
private_key = Xgt::Ruby::Auth.generate_wif(wallet, master, role)
public_key = Xgt::Ruby::Auth.wif_to_public_key(private_key, address_prefix)
ks["#{role}_private"] = private_key
ks["#{role}_public"] = public_key
end
response = rpc.call('wallet_by_key_api.generate_wallet_name', {
'recovery_keys' => [ks['recovery_public']]
})
ks['wallet_name'] = response['wallet_name']
f.puts(JSON.pretty_generate(ks))
end
}

keys = ->() {
JSON.load(File.open('out/keys.json'))
}
response = rpc.call('wallet_by_key_api.generate_wallet_name', {
'recovery_keys' => [ks['recovery_public']]
})
wallet_name = response['wallet_name']
ks['wallet_name'] = wallet_name

does_witness_exist = ->() {
name = wallet_name.call
response = rpc.call('database_api.list_witnesses', { 'start' => name, 'limit' => 1, 'order' => 'by_name'}) || {}
witnesses = response['witnesses'] || []
witness = witnesses.first || {}
(name == witness['owner'])
}

desc 'Generate the keys for the witness'
task :generate_keys do
generate_keys.call
end

desc 'Create a wallet for the witness'
task :create_wallet do
name = keys.call['wallet_name']

txn = {
'extensions' => [],
'operations' => [
{
'type' => 'wallet_create_operation',
'value' => {
'fee' => {
'amount' => '0',
'precision' => 8,
'nai' => '@@000000021'
},
'creator' => wallet,
'recovery' => {
'weight_threshold' => 1,
'account_auths' => [],
'key_auths' => [[keys.call['recovery_public'], 1]]
},
'money' => {
'weight_threshold' => 1,
'account_auths' => [],
'key_auths' => [[keys.call['money_public'], 1]]
},
'social' => {
'weight_threshold' => 1,
'account_auths' => [],
'key_auths' => [[keys.call['social_public'], 1]]
},
'memo_key' => keys.call['memo_public'],
'json_metadata' => '',
'extensions' => []
}
}
]
}

$stderr.puts(%(Creator is "#{wallet}" with wif "#{wif}"...))
$stderr.puts(%(Creating wallet with master key "#{keys.call['master']}"...))
signed = Xgt::Ruby::Auth.sign_transaction(rpc, txn, [wif], chain_id)
rpc.call('transaction_api.broadcast_transaction', [signed])
end

desc 'Register the witness'
task :register do
name = keys.call['wallet_name']

components = fee.split(' ')
decimal = BigDecimal(components.first) * 1
final_fee = decimal.truncate.to_s + '.' + sprintf('%03d', (decimal.frac * 1000).truncate) + ' ' + components.last
ks
end

# raise 'Witness already registered!' if does_witness_exist.call
def create_wallet!(keys)
name = keys['wallet_name']

txn = {
'extensions' => [],
'operations' => [{
'type' => 'witness_update_operation',
txn = {
'extensions' => [],
'operations' => [
{
'type' => 'wallet_create_operation',
'value' => {
'owner' => name,
'url' => 'http://witness-category/my-witness',
'block_signing_key' => keys.call['witness_public'],
'props' => {
'account_creation_fee' => {'amount'=>'0','precision'=>8,'nai'=>'@@000000021'}
'fee' => {
'amount' => '0',
'precision' => 8,
'nai' => '@@000000021'
},
'creator' => wallet,
'recovery' => {
'weight_threshold' => 1,
'account_auths' => [],
'key_auths' => [[keys['recovery_public'], 1]]
},
'money' => {
'weight_threshold' => 1,
'account_auths' => [],
'key_auths' => [[keys['money_public'], 1]]
},
'social' => {
'weight_threshold' => 1,
'account_auths' => [],
'key_auths' => [[keys['social_public'], 1]]
},
'fee' => {'amount'=>'0','precision'=>8,'nai'=>'@@000000021'}
'memo_key' => keys['memo_public'],
'json_metadata' => '',
'extensions' => []
}
}]
}
}
]
}

$stderr.puts(%(Creator is "#{wallet}" with wif "#{wif}"...))
$stderr.puts(%(Creating wallet with master key "#{keys['master']}"...))
signed = Xgt::Ruby::Auth.sign_transaction(rpc, txn, [wif], chain_id)
rpc.call('transaction_api.broadcast_transaction', [signed])
name
end

signing_keys = keys.call['recovery_private']
signed = Xgt::Ruby::Auth.sign_transaction(rpc, txn, [signing_keys], chain_id)
$stderr.puts(%(Registering witness with recovery private WIF "#{keys.call['recovery_private']}"...))
$stderr.puts(%(Signing keypair is #{keys.call['witness_private']} (private) and #{keys.call['witness_public']} (public)...))
response = rpc.call('transaction_api.broadcast_transaction', [signed])
$stderr.puts(%(Registered witness #{name}))
end
namespace :machine do
src_dir = File.join(File.dirname(__FILE__), %(../xgtvm))
dest_dir = File.join(File.dirname(__FILE__), %(libraries/vendor/xgtvm))
dest_git_dir = File.join(dest_dir, '.git')

desc 'Assuming keys were generated, do everything else'
task :all => [:create_wallet, :register]

desc 'Regenerate keys and do everything else'
task :really_all => [:generate_keys, :create_wallet, :register]
end

namespace :contracts do
desc 'Generate a sample contract'
task :generate do
txn = {
'extensions' => [],
'operations' => [
{
'type' => 'contract_create_operation',
'value' => {
'owner' => wallet,
'code' => "600260030100",
}
}
]
}
signed = Xgt::Ruby::Auth.sign_transaction(rpc, txn, [wif], chain_id)
$stderr.puts(%(Registering contract... #{signed.to_json}))
response = rpc.call('transaction_api.broadcast_transaction', [signed])
$stderr.puts(%(Received response contract... #{response}))
desc 'Remove machine-related files'
task :clean do
FileUtils.rm_r(dest_dir) if Dir.exist?(dest_dir)
end

desc 'View sample contracts'
task :list do
response = rpc.call('contract_api.list_owner_contracts', { 'owner' => wallet }) || {}
p response
desc 'Vendor machine-related files'
task :vendor => [:clean] do
raise %(Directory #{src_dir} doesn't exist!) unless Dir.exist?(src_dir)
FileUtils.cp_r(src_dir, dest_dir)
FileUtils.rm_r(dest_git_dir) if File.exists?(dest_git_dir)
end
end
Loading