Skip to content

Commit

Permalink
Upgrade php laravel (#106)
Browse files Browse the repository at this point in the history
* upgrade php

* Update version.json
  • Loading branch information
art-cmyk authored Jul 23, 2024
1 parent 6d6b4f9 commit 8eff7c7
Show file tree
Hide file tree
Showing 13 changed files with 168 additions and 65 deletions.
18 changes: 13 additions & 5 deletions scripts/setup-vasp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -144,19 +144,27 @@ function install_redis_bloom {
mv /tmp/redis.conf /etc/redis/redis.conf
systemctl restart redis-server

sed -i 's/^.*post_max_size.*/post_max_size = 128M/' /etc/php/8.0/fpm/php.ini
sed -i 's/^.*upload_max_filesize .*/upload_max_filesize = 128M/' /etc/php/8.0/fpm/php.ini
sed -i 's/^.*post_max_size.*/post_max_size = 128M/' /etc/php/8.2/fpm/php.ini
sed -i 's/^.*upload_max_filesize .*/upload_max_filesize = 128M/' /etc/php/8.2/fpm/php.ini
if grep -q client_max_body_size $NGINX_CFG; then
echo "NGINX config already has been already updated"
else
sed -i 's/listen 443 ssl;/listen 443 ssl;\n client_max_body_size 128M;/' $NGINX_CFG
fi

pushd >/dev/null $INSTALL_ROOT/veriscope_ta_dashboard

# double confirm bloom filter folder permission
directory="storage/app/files"
if [ ! -d "$directory" ]; then
mkdir -p "$directory"
fi

chmod 775 "$directory"
chown -R $SERVICE_USER .
su $SERVICE_USER -c "composer update"

systemctl restart php8.0-fpm
systemctl restart php8.2-fpm
systemctl restart nginx

else
Expand Down Expand Up @@ -198,7 +206,7 @@ function refresh_dependencies() {

DEBIAN_FRONTEND=noninteractive apt -y upgrade

DEBIAN_FRONTEND=noninteractive apt-get -qq -y -o Acquire::https::AllowRedirect=false install vim git libsnappy-dev libc6-dev libc6 unzip make jq ntpdate moreutils php8.0-fpm php8.0-dom php8.0-zip php8.0-mbstring php8.0-curl php8.0-dom php8.0-gd php8.0-imagick php8.0-pgsql php8.0-gmp php8.0-redis php8.0-mbstring nodejs build-essential postgresql nginx pwgen certbot
DEBIAN_FRONTEND=noninteractive apt-get -qq -y -o Acquire::https::AllowRedirect=false install vim git libsnappy-dev libc6-dev libc6 unzip make jq ntpdate moreutils php8.2-fpm php8.2-dom php8.2-zip php8.2-mbstring php8.2-curl php8.2-dom php8.2-gd php8.2-imagick php8.2-pgsql php8.2-gmp php8.2-redis php8.2-mbstring nodejs build-essential postgresql nginx pwgen certbot
apt-get install -y protobuf-compiler libtiff5-dev libjpeg8-dev libopenjp2-7-dev zlib1g-dev \
libfreetype6-dev liblcms2-dev libwebp-dev tcl8.6-dev tk8.6-dev python3-tk python3-pip \
libharfbuzz-dev libfribidi-dev libxcb1-dev
Expand Down Expand Up @@ -410,7 +418,7 @@ function setup_nginx {
} ' >$NGINX_CFG

systemctl enable nginx
systemctl restart php8.0-fpm
systemctl restart php8.2-fpm
systemctl restart nginx
}

Expand Down
2 changes: 1 addition & 1 deletion veriscope_ta_dashboard/app/Http/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Kernel extends HttpKernel
protected $middleware = [
// \App\Http\Middleware\TrustHosts::class,
\App\Http\Middleware\TrustProxies::class,
\Fruitcake\Cors\HandleCors::class,
\Illuminate\Http\Middleware\HandleCors::class,
\App\Http\Middleware\PreventRequestsDuringMaintenance::class,
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
\App\Http\Middleware\TrimStrings::class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use App\Plugins\SystemChecks\Check;
use GuzzleHttp\Client;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Facades\Redis;
use Illuminate\Support\Facades\Config;

class EthSyncCheck implements Check
Expand All @@ -17,8 +16,9 @@ public function getId()

public function run()
{

Config::set('database.redis.options.prefix', '');
$redis = new \Redis();
$redis->connect(env('REDIS_HOST'), env('REDIS_PORT'));
$redis->setOption(\Redis::OPT_PREFIX, '');

$result = ['success' => false, 'message' => ''];
$path = base_path('../veriscope_ta_node/.env');
Expand Down Expand Up @@ -74,7 +74,7 @@ public function run()
if ($currentBlockNumber >= ($highestBlockNumber - 2)) {

// Check Redis key for startBlock value
$redisValue = Redis::get('keyv:startBlock');
$redisValue = $redis->get('keyv:startBlock');
$decodedValue = json_decode($redisValue, true);

if ($decodedValue && isset($decodedValue['value'])) {
Expand All @@ -95,6 +95,7 @@ public function run()

return $result;
}

} catch (\Exception $e) {
$result['message'] = 'Nethermind is not running due to an error: ' . $e->getMessage();
return $result;
Expand Down
27 changes: 12 additions & 15 deletions veriscope_ta_dashboard/app/Providers/AuthServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ public function boot()
{
$this->registerPolicies();

// Passport::routes();

Gate::define('grant-users', function ($user) {
return $user->inGroup('admin');
});
Expand All @@ -38,24 +36,23 @@ public function boot()
});

if (! $this->app->routesAreCached()) {
Passport::routes();

Passport::tokensCan([
'set_attestation' => 'Set Attestation',
'create_shyft_user' => 'Create Shyft User',
'get_jurisdictions' => 'Get Jurisdiction',
'get_verified_trust_anchors' => 'Get Verified Trust Anchors',
'get_trust_anchor_details' => 'Get Trust Anchor Details',
'verify_trust_anchor' => 'Verify Trust Anchor'
'set_attestation' => 'Set Attestation',
'create_shyft_user' => 'Create Shyft User',
'get_jurisdictions' => 'Get Jurisdiction',
'get_verified_trust_anchors' => 'Get Verified Trust Anchors',
'get_trust_anchor_details' => 'Get Trust Anchor Details',
'verify_trust_anchor' => 'Verify Trust Anchor'
]);

Passport::setDefaultScope([
'set_attestation',
'create_shyft_user',
'get_jurisdictions',
'get_verified_trust_anchors',
'get_trust_anchor_details',
'verify_trust_anchor'
'set_attestation',
'create_shyft_user',
'get_jurisdictions',
'get_verified_trust_anchors',
'get_trust_anchor_details',
'verify_trust_anchor'
]);
}
}
Expand Down
18 changes: 9 additions & 9 deletions veriscope_ta_dashboard/app/Support/EthereumToolsUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -425,15 +425,15 @@ public static function toInt32Bits($value)
* @return string
*/
public static function hexToStr($value)
{
$string='';
for ($i=0; $i < strlen($value)-1; $i+=2)
{
if ( $value[$i] == ' ') continue;
$string .= chr(hexdec($value[$i].$value[$i+1]));
}
return $string;
}
{
$string='';
for ($i=0; $i < strlen($value)-1; $i+=2)
{
if ( $value[$i] == ' ') continue;
$string .= chr(hexdec($value[$i].$value[$i+1]));
}
return $string;
}

/**
* Encrypt Data
Expand Down
2 changes: 1 addition & 1 deletion veriscope_ta_dashboard/app/Token.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function getPersonalAccessTokenResult()
);

$now = new DateTimeImmutable();
$expiresAt = new DateTimeImmutable($this->expires_at->toDateTimeString());
$expiresAt = new DateTimeImmutable($this->expires_at);

$token = $configuration->builder()
->permittedFor($this->client_id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function getPersonalAccessTokenResult($client_id, $token_id, $user_id, $e
);

$now = new DateTimeImmutable();
$expiresAt = new DateTimeImmutable($expires_at->toDateTimeString());
$expiresAt = new DateTimeImmutable($expires_at);

$token = $configuration->builder()
->permittedFor($client_id)
Expand Down
77 changes: 51 additions & 26 deletions veriscope_ta_dashboard/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,62 +6,87 @@
"repositories":[
{
"type": "git",
"url": "https://github.com/hackable/roles.git"
"url": "https://github.com/ShyftNetwork/roles.git"
},
{
"type": "git",
"url": "https://github.com/hackable/ethereum-address-validator.git"
"url": "https://github.com/ShyftNetwork/ethereum-address-validator.git"
},
{
"type": "git",
"url": "https://github.com/ShyftNetwork/EloquentEncryption.git"
},
{
"type": "git",
"url": "https://github.com/ShyftNetwork/laravel-eloquent-state-machines.git"
},
{
"type": "git",
"url": "https://github.com/ShyftNetwork/laravel-websockets.git"
},
{
"type": "git",
"url": "https://github.com/ShyftNetwork/html.git"
},
{
"type": "git",
"url": "https://github.com/ShyftNetwork/Ratchet.git"
},
{
"type": "git",
"url": "https://github.com/ShyftNetwork/glide-laravel.git"
}
],
"require": {
"php": "^7.3|^8.0",
"asantibanez/laravel-eloquent-state-machines": "^5.1",
"bayareawebpro/laravel-simple-csv": "^2.0",
"php": "^8.0",
"cboden/ratchet": "v0.6.1",
"asantibanez/laravel-eloquent-state-machines": "dev-master",
"bayareawebpro/laravel-simple-csv": "v2.2.0",
"bacon/bacon-qr-code": "^2.0",
"beyondcode/laravel-websockets": "^1.13",
"beyondcode/laravel-websockets": "1.18.0",
"digitaldonkey/ecverify": "^1.0",
"doctrine/dbal": "^3.1",
"firebase/php-jwt": "^5.5",
"fruitcake/laravel-cors": "^2.0",
"doctrine/dbal": "^3.0",
"firebase/php-jwt": "^6.10",
"guzzlehttp/guzzle": "^7.0.1",
"httpoz/roles": "master",
"kornrunner/ethereum-address": "^0.3.0",
"laravel/framework": "^8.54",
"laravel/framework": "^11.0",
"laravel/horizon": "^5.8",
"laravel/legacy-factories": "^1.1",
"laravel/passport": "^10.1",
"laravel/passport": "v12.2.0",
"laravel/tinker": "^2.5",
"laravel/ui": "^3.3",
"laravelcollective/html": "^6.2",
"laravel/ui": "^4.5",
"laravelcollective/html": "v6.7.0",
"league/csv": "^9.7",
"league/glide-laravel": "^1.0",
"league/glide-laravel": "^2.1",
"opis/json-schema": "^2.2",
"php-redis/bloom-filter": "^1.1",
"pragmarx/google2fa-laravel": "^1.4",
"psychob/ethereum-address-validator": "dev-master",
"pusher/pusher-php-server": "7.0.2",
"richardstyles/eloquentencryption": "v3.1.0",
"s-ichikawa/laravel-sendgrid-driver": "^3.0",
"pragmarx/google2fa-laravel": "^2.0",
"pusher/pusher-php-server": "7.2.4",
"richardstyles/eloquentencryption": "v3.4",
"s-ichikawa/laravel-sendgrid-driver": "^4.0",
"sebdesign/laravel-state-machine": "^3.2",
"sentry/sentry-laravel": "^2.8",
"sentry/sentry-laravel": "^4.0",
"simplesoftwareio/simple-qrcode": "^4.2",
"simplito/elliptic-php": "^1.0",
"spatie/laravel-activitylog": "^4.1",
"spatie/laravel-webhook-server": "^3.1",
"msztorc/laravel-env": "^1.2",
"spatie/laravel-fractal": "^6.0",
"abagayev/laravel-migration-shortcuts": "*",
"nelexa/zip": "^4.0",
"web3p/web3.php": "0.2.1",
"laravel/slack-notification-channel": "^2.5"
"laravel/slack-notification-channel": "^3.0",
"abagayev/laravel-migration-shortcuts": "*",
"psychob/ethereum-address-validator": "dev-master",
"httpoz/roles": "dev-master",
"nesbot/carbon": "^2.72.2"
},
"require-dev": {
"facade/ignition": "^2.5",
"spatie/laravel-ignition": "^2.0",
"fakerphp/faker": "^1.9.1",
"laravel/sail": "^1.0.1",
"mockery/mockery": "^1.4.2",
"nunomaduro/collision": "^5.0",
"phpunit/phpunit": "^9.3.3"
"nunomaduro/collision": "^v8.0.0",
"phpunit/phpunit": "^10.5.1"
},
"autoload": {
"psr-4": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ public function up()
// next up, create the countries
$path = 'app/SqlDumps/countries.sql';
DB::unprepared(file_get_contents($path));
DB::unprepared(DB::raw('UPDATE countries SET created_at=\''.Carbon::NOW().'\', updated_at=\''.Carbon::NOW().'\';'));
// DB::unprepared(DB::raw('UPDATE countries SET created_at=\''.Carbon::NOW().'\', updated_at=\''.Carbon::NOW().'\';')); // this is used by laravel 8 & 9
$now = Carbon::now()->toDateTimeString();
DB::unprepared("UPDATE countries SET created_at='{$now}', updated_at='{$now}';");
//$this->command->info('Country table seeded!');
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ public function up()
$path = 'app/SqlDumps/states.sql';
DB::unprepared(file_get_contents($path));
//DB::unprepared(DB::raw('UPDATE states SET created_at=NOW(), updated_at=NOW();'));
DB::unprepared(DB::raw('UPDATE states SET created_at=\''.Carbon::NOW().'\', updated_at=\''.Carbon::NOW().'\';'));
// DB::unprepared(DB::raw('UPDATE states SET created_at=\''.Carbon::NOW().'\', updated_at=\''.Carbon::NOW().'\';'));
$now = Carbon::now()->toDateTimeString();
DB::unprepared("UPDATE states SET created_at='{$now}', updated_at='{$now}';");
//$this->command->info('State table seeded!');
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
/**
* Run the migrations.
* In laravel 11 need to change the column setting format like below.
*/
public function up(): void
{
Schema::table('kyc_templates', function (Blueprint $table) {
$table->longText('beneficiary_kyc')->change()->nullable();
$table->longText('sender_kyc')->change()->nullable();
$table->longText('beneficiary_user_address_crypto_proof')->change()->nullable();
$table->longText('sender_user_address_crypto_proof')->change()->nullable();
});
}

/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('kyc_templates', function (Blueprint $table) {
$table->longText('beneficiary_kyc')->nullable()->change();
$table->longText('sender_kyc')->nullable()->change();
$table->longText('beneficiary_user_address_crypto_proof')->nullable()->change();
$table->longText('sender_user_address_crypto_proof')->nullable()->change();
});
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
/**
* Run the migrations.
* In laravel 11 need to change the column setting format like below.
*/
public function up(): void
{
Schema::table('smart_contract_transactions', function (Blueprint $table) {
$table->bigInteger('gas_price')->change()->nullable();
$table->bigInteger('gas')->change()->nullable();
$table->bigInteger('value')->change()->nullable();
});
}

/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('smart_contract_transactions', function (Blueprint $table) {
$table->bigInteger('gas_price')->nullable()->change();
$table->bigInteger('gas')->nullable()->change();
$table->bigInteger('value')->nullable()->change();
});
}
};
2 changes: 1 addition & 1 deletion veriscope_ta_dashboard/storage/app/version.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"veriscopeVersion": "4.4.0"
"veriscopeVersion": "4.5.0"
}

0 comments on commit 8eff7c7

Please sign in to comment.